title: inserting a node after a specific node in xml file
body: <p>i'm re posting my question in a simpler way.</p>
  
  <p>i need to search for a specific node in a XML file, and once i see it, i need to create a new node and insert it after that. the problem is that there are 2 nodes with the same value. and i need to insert the new node twice after each instance. with the code below: it's inserting the new nodes twice but in the same place after the first instance only.</p>
  
  <p>original XML:</p>
  
  <pre><code>&lt;eventlist&gt;
    &lt;event type="AUDIOPLAYER"&gt;
      &lt;properties&gt;
        &lt;schedule startType="-ParentEnd1" /&gt;
        &lt;media mediaType="Audio" /&gt;
      &lt;/properties&gt;
    &lt;/event&gt;
    &lt;event type="AUDIOPLAYER"&gt;
      &lt;properties&gt;
        &lt;schedule startType="-ParentEnd2" /&gt;
        &lt;media mediaType="Audio" /&gt;
      &lt;/properties&gt;
    &lt;/event&gt;
  &lt;/eventlist&gt;
  </code></pre>
  
  <p>intended XML:</p>
  
  <pre><code>&lt;eventlist&gt;
    &lt;event type="AUDIOPLAYER"&gt;
      &lt;properties&gt;
        &lt;schedule startType="-ParentEnd1" /&gt;
        &lt;media mediaType="Audio" /&gt;
      &lt;/properties&gt;
    &lt;/event&gt;
    &lt;event type="VIZ" /&gt;
    &lt;event type="AUDIOPLAYER"&gt;
      &lt;properties&gt;
        &lt;schedule startType="-ParentEnd2" /&gt;
        &lt;media mediaType="Audio" /&gt;
      &lt;/properties&gt;
    &lt;/event&gt;
      &lt;event type="VIZ" /&gt;
  &lt;/eventlist&gt;
  </code></pre>
  
  <p>but the current output is:</p>
  
  <pre><code>&lt;eventlist&gt;
    &lt;event type="AUDIOPLAYER"&gt;
      &lt;properties&gt;
        &lt;schedule startType="-ParentEnd1" /&gt;
        &lt;media mediaType="Audio" /&gt;
      &lt;/properties&gt;
    &lt;/event&gt;
    &lt;event type="VIZ" /&gt;
    &lt;event type="VIZ" /&gt;
    &lt;event type="AUDIOPLAYER"&gt;
      &lt;properties&gt;
        &lt;schedule startType="-ParentEnd2" /&gt;
        &lt;media mediaType="Audio" /&gt;
      &lt;/properties&gt;
    &lt;/event&gt;
  &lt;/eventlist&gt;
  </code></pre>
  
  <p>the code is below here:</p>
  
  <pre><code>    XmlDocument xdoc = new XmlDocument();
      xdoc.Load(@"C:\Users\namokhtar\Desktop\newxml\testxml.xml");
  
      foreach (XmlNode node in xdoc.SelectNodes("/eventlist/event[@type='AUDIOPLAYER']"))
      {
          XmlNode srcNode = node.SelectSingleNode("/eventlist/event[@type='AUDIOPLAYER']");
          XmlNode newElem = xdoc.CreateElement("event");
          XmlAttribute newAttr = xdoc.CreateAttribute("type");
          newAttr.Value = "VIZ";
          newElem.Attributes.Append(newAttr);
          srcNode.ParentNode.InsertAfter(newElem, srcNode);
      }
  
      xdoc.Save(@"C:\Users\namokhtar\Desktop\newxml\newxml1.xml");
  </code></pre>
  
  <p>please advise me...</p>