title: How to append a existing xml file ?
body: <p>I have a xml file and I want to modified/append it by adding some nodes. 
  I have written a below code </p>
  
  <p>its giving an error  - </p>
  
  <blockquote>
    <p>Cannot insert a node or any ancestor of that node as a child of
    itself.</p>
  </blockquote>
  
  <p>Code- </p>
  
  <pre><code>            Dim xdoc1 As New XmlDocument()
             xdoc1.Load("C:\xml1.xml1")
  
             Dim TrialNo As XmlNode = xdoc1.CreateElement("TrialNo")
  
             Dim TotalNoOfTrials = GetTotalNoOfTrials()
             TrialNo.InnerText = TotalNoOfTrials + 1
  
             TrialNo.AppendChild(name1)
  
             xdoc1.Save(Path)
  </code></pre>
  
  <p>I have below existing file </p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; 
        &lt;Data&gt; 
        &lt;TrialNo&gt;1&lt;/TrialNo&gt;
        &lt;/Data&gt;
  </code></pre>
  
  <p>and I want to append file like </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; 
        &lt;Data&gt; 
        &lt;TrialNo&gt;1&lt;/TrialNo&gt;
        &lt;TrialNo&gt;2&lt;/TrialNo&gt;
        &lt;TrialNo&gt;3&lt;/TrialNo&gt;
       &lt;/Data&gt;
  </code></pre>