title: Inserting XML node at specific position
body: <p>I have an XML file and I am loading it in Xmldocument. This document has a node with some child nodes like this</p>
  
  <pre><code>&lt;xml here&gt;
   &lt;somenode&gt;
     &lt;child&gt; &lt;/child&gt;
     &lt;children&gt;&lt;/children&gt;
     &lt;children&gt;&lt;/children&gt;
     &lt;children&gt;&lt;/children&gt;  // I need to insert it
     &lt;children&gt;&lt;/children&gt;  // I need to insert this second time
     &lt;children&gt;&lt;/children&gt;
     &lt;children&gt;&lt;/children&gt;
     &lt;child&gt; &lt;/child&gt;
   &lt;somenode&gt;
  &lt;xml here&gt;
  </code></pre>
  
  <p>here somenode has some children where first and last children node names are same where as other nodes except the first and last node has some diffrent name ( identical to each other ). I am creating a function to insert a node at specific position, I am not sure about the criteria but may be in the mid.</p>
  
  <ul>
  <li>how can I insert node in specific position. I am using XMLnode.appendChild method for insertion </li>
  <li>Do I need to rearrange/sort nodes after insertion. Please suggest. </li>
  <li>How can I determine what is structure and how should I find where the new node should be added according to current document structure.</li>
  </ul>