title: how to remove all the childnodes of the specified xmlnode in C# 4.0?
body: <p>This is my xml.</p>
  
  <pre><code>&lt;Document&gt;
  &lt;page no="1"&gt;
    &lt;Paragraph no="1"&gt;
      &lt;Line&gt;line1&lt;/Line&gt;
    &lt;/Paragraph&gt;
    &lt;Paragraph no="2"&gt;
      &lt;Line&gt;line2&lt;/Line&gt;
    &lt;/Paragraph&gt;
  &lt;/page&gt;
  &lt;page no="2"&gt;
    &lt;Paragraph no="1"&gt;
      &lt;Line&gt;line1&lt;/Line&gt;
    &lt;/Paragraph&gt;
    &lt;Paragraph no="2"&gt;
      &lt;Line&gt;line2&lt;/Line&gt;
    &lt;/Paragraph&gt;
  &lt;/page&gt;
  &lt;/Document&gt;
  </code></pre>
  
  <p>My C# code is </p>
  
  <pre><code>XmlDocument xd = new XmlDocument();
              xd.Load(@"H:\Sample-8-final.xml");
              XmlNodeList pnodelist = xd.GetElementsByTagName("page");
              XmlNodeList xdChildNodeList = xd.ChildNodes;
  
              for (int i = 0; i &lt; pnodelist.Count; i++)
              {
                  XmlNode pageNode = pnodelist[i];
                  foreach (XmlNode xxNode in pageNode.ChildNodes)
                  {
                      if (xxNode.Name.ToString().Trim().Equals("Paragraph"))
                      {
                          foreach (XmlNode yyNode in xxNode.ChildNodes)
                          {
                              yyNode.ParentNode.RemoveChild(yyNode);
                          }
                      }
                  }
                  xd.Save(@"H:\Sample-8-final_1.xml");
  </code></pre>
  
  <p>my Required output is </p>
  
  <pre><code>&lt;Document&gt;
  &lt;page no="1"&gt;
    &lt;Paragraph no="1"&gt;
    &lt;/Paragraph&gt;
    &lt;Paragraph no="2"&gt;
    &lt;/Paragraph&gt;
  &lt;/page&gt;
  &lt;page no="2"&gt;
    &lt;Paragraph no="1"&gt;
    &lt;/Paragraph&gt;
    &lt;Paragraph no="2"&gt;
    &lt;/Paragraph&gt;
  &lt;/page&gt;
  &lt;/Document&gt;
  </code></pre>
  
  <p>but my code produced wrong result like below:</p>
  
  <pre><code>&lt;Document&gt;
      &lt;page no="1"&gt;
        &lt;Paragraph no="1"&gt;
        &lt;/Paragraph&gt;
        &lt;Paragraph no="2"&gt;
          &lt;Line&gt;line2&lt;/Line&gt;
        &lt;/Paragraph&gt;
      &lt;/page&gt;
      &lt;page no="2"&gt;
        &lt;Paragraph no="1"&gt;
        &lt;/Paragraph&gt;
        &lt;Paragraph no="2"&gt;
          &lt;Line&gt;line2&lt;/Line&gt;
        &lt;/Paragraph&gt;
      &lt;/page&gt;
      &lt;/Document&gt;
  </code></pre>
  
  <p>Please Guide me to get out of this issue...</p>