<p>I have an XmlDocument that already exists and is read from a file. </p>

<p>I would like to add a chunk of Xml to a node in the document. Is there a good way to create and add all the nodes without cluttering my code with many .CreateNote and .AppendChild calls?</p>

<p>I would like some way of making a string or stringBuilder of a valid Xml section and just appending that to an XmlNode.</p>

<p>ex:
Original XmlDoc:</p>

<pre><code>&lt;MyXml&gt;
   &lt;Employee&gt;
   &lt;/Employee&gt;
&lt;/MyXml&gt;
</code></pre>

<p>and, I would like to add a Demographic (with several children) tag to Employee:</p>

<pre><code>&lt;MyXml&gt;
   &lt;Employee&gt;
      &lt;Demographic&gt;
         &lt;Age/&gt;
         &lt;DOB/&gt;
      &lt;/Demographic&gt;
   &lt;/Employee&gt;
&lt;/MyXml&gt;
</code></pre>

I suggest using
XmlDocument.CreateDocumentFragment
if you have the data in free form strings. You'll still have to use AppendChild to add the fragment to a node, but you have the freedom of building the XML in your StringBuilder.
```
```
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(@"<MyXml><Employee></Employee></MyXml>");

XmlDocumentFragment xfrag = xdoc.CreateDocumentFragment();
xfrag.InnerXml = @"<Demographic><Age/><DOB/></Demographic>";

xdoc.DocumentElement.FirstChild.AppendChild(xfrag);
```
```