title: Remove an XML parent node keeping child nodes
body: <p>If I have (for example) an XML file with the following structure:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;Parent1&gt;
        &lt;listChild&gt;
             &lt;child&gt;
                 &lt;listchild2&gt;
                      &lt;child2&gt;
                      &lt;child2&gt;
                      &lt;child2&gt;
                 &lt;/listchild2&gt;
             &lt;/child&gt;
             &lt;child&gt;
                  &lt;listchild2&gt;
                       &lt;child2&gt;
                       &lt;child2&gt;
                       &lt;child2&gt;
                  &lt;/listchild2&gt;
             &lt;/child&gt;
        &lt;/listchild&gt;
  &lt;/parent1&gt;
  </code></pre>
  
  <p>I want to remove <code>listChild</code> and <code>listChild2</code>, with the expected output:</p>
  
  <pre class="lang-xml prettyprint-override"><code> &lt;Parent&gt;
         &lt;child&gt;
            &lt;child&gt;
            &lt;child&gt;
            &lt;child&gt;
         &lt;/child&gt;
         &lt;child&gt;
            &lt;child&gt;
            &lt;child&gt;
            &lt;child&gt;
         &lt;/child&gt;
  &lt;/parent&gt;
  </code></pre>
  
  <p>I tried <code>System.Xml.Linq</code>, like this:</p>
  
  <pre><code>public void removeParentNode(String filename)
  {
      XDocument xdoc = XDocument.Load(filename);
  
      //remove parent1 
      var child= xdoc.Descendants("child");                       
      XElement dcuManager = new XElement("parent1 ");
      parent1 .Add(child);
  
      XDocument xdoc1 = new XDocument(dcuManager);
  }
  </code></pre>
  
  <p>But the code removes only the outer list.</p>
  
  <p>Is there a way to remove the <code>&lt;listchild&gt;</code> and <code>&lt;/listchild&gt;</code> tags only, keeping all its child nodes?</p>
  
  <p>------------------------update-------------------------------------</p>
  
  <p>above xml code is very simple example
  my xml code is :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;DcuManager xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;listDcu&gt;
      &lt;Dcu id="dcu1 id" mode="dcu1 mode" port="dcu1 port"&gt;
        &lt;modemMgr&gt;
          &lt;listModem&gt;
            &lt;Modem id="Modem1 id" port="modem 1 port" communicationStatus="modem 1 mode"&gt;
              &lt;meterManager&gt;
                &lt;listMeter&gt;
                  &lt;Meter id="Meter 1 id" port="Meter 1 port" mac="Meter 1 mode" /&gt;
                &lt;/listMeter&gt;
              &lt;/meterManager&gt;
            &lt;/Modem&gt;
            &lt;Modem id="Modem2 id" port="modem 2 port" communicationStatus="modem 2 mode"&gt;
              &lt;meterManager&gt;
                &lt;listMeter&gt;
                  &lt;Meter id="Meter 2 id" port="Meter 2 port" mac="Meter 2 mode" /&gt;
                &lt;/listMeter&gt;
              &lt;/meterManager&gt;
            &lt;/Modem&gt;
          &lt;/listModem&gt;
        &lt;/modemMgr&gt;
      &lt;/Dcu&gt;
      &lt;Dcu id="dcu2 id" mode="dcu2 mode" port="dcu2 port"&gt;
        &lt;modemMgr&gt;
          &lt;listModem&gt;
            &lt;Modem id="Modem3 id" port="modem 3 port" communicationStatus="modem 3 mode"&gt;
              &lt;meterManager&gt;
                &lt;listMeter&gt;
                  &lt;Meter id="Meter 3 id" port="Meter 3 port" mac="Meter 3 mode" /&gt;
                &lt;/listMeter&gt;
              &lt;/meterManager&gt;
            &lt;/Modem&gt;
            &lt;Modem id="Modem4 id" port="modem 4 port" communicationStatus="modem 4 mode"&gt;
              &lt;meterManager&gt;
                &lt;listMeter&gt;
                  &lt;Meter id="Meter 4 id" port="Meter 4 port" mac="Meter 4 mode" /&gt;
                &lt;/listMeter&gt;
              &lt;/meterManager&gt;
            &lt;/Modem&gt;
          &lt;/listModem&gt;
        &lt;/modemMgr&gt;
      &lt;/Dcu&gt;
      &lt;Dcu id="dcu3 id" mode="dcu3 mode" port="dcu3 port"&gt;
        &lt;modemMgr&gt;
          &lt;listModem&gt;
            &lt;Modem id="Modem5 id" port="modem 5 port" communicationStatus="modem 5 mode"&gt;
              &lt;meterManager&gt;
                &lt;listMeter&gt;
                  &lt;Meter id="Meter 5 id" port="Meter 5 port" mac="Meter 5 mode" /&gt;
                &lt;/listMeter&gt;
              &lt;/meterManager&gt;
            &lt;/Modem&gt;
            &lt;Modem id="Modem6 id" port="modem 6 port" communicationStatus="modem 6 mode"&gt;
              &lt;meterManager&gt;
                &lt;listMeter&gt;
                  &lt;Meter id="Meter 6 id" port="Meter 6 port" mac="Meter 6 mode" /&gt;
                &lt;/listMeter&gt;
              &lt;/meterManager&gt;
            &lt;/Modem&gt;
          &lt;/listModem&gt;
        &lt;/modemMgr&gt;
      &lt;/Dcu&gt;
    &lt;/listDcu&gt;
  &lt;/DcuManager&gt;
  </code></pre>
  
  <p>this code is convert c# class to xml.
  i want remove dcuMgr, modemMgr, meterMgr keeping child nodes.
  how do i?</p>