title: Remove all child nodes from the parent except one specific, an xml in c #
body: <p>This is Xml</p>
  
  <pre><code> &lt;ItemWarehouseInfo&gt;
        &lt;row&gt;
          &lt;MinimalStock&gt;0.000000&lt;/MinimalStock&gt;
          &lt;MaximalStock&gt;0.000000&lt;/MaximalStock&gt;
          &lt;MinimalOrder&gt;0.000000&lt;/MinimalOrder&gt;
          &lt;StandardAveragePrice&gt;0.000000&lt;/StandardAveragePrice&gt;
          &lt;Locked&gt;tNO&lt;/Locked&gt;
          &lt;WarehouseCode&gt;Mc&lt;/WarehouseCode&gt;
          &lt;DefaultBinEnforced&gt;tNO&lt;/DefaultBinEnforced&gt;
        &lt;/row&gt;
        ...other equal lines
      &lt;/ItemWarehouseInfo&gt;
  </code></pre>
  
  <p>I have to remove all child nodes from every row node except for the WarehouseCode node
  I tried this method but obviously I'm wrong and nothing changes:</p>
  
  <pre><code>    XDocument xdoc = XmlHelper.LoadXDocFromString(xmlOITM);
  XElement magaRow = xdoc.Root.Descendants(Constants.Articoli.ART_MAGA_NODES).FirstOrDefault();//ItemWarehouseInfo node
  List&lt;XElement&gt; row = magaRow.Elements().ToList();//row node
  foreach(XElement child in row.Elements())
  {
      if (child.Name != "WarehouseCode")
      {
          child.Remove();
      }
  }
  </code></pre>
  
  <p>This is the final result that I expect:</p>
  
  <pre><code>&lt;ItemWarehouseInfo&gt;
        &lt;row&gt;
          &lt;WarehouseCode&gt;Mc&lt;/WarehouseCode&gt;
        &lt;/row&gt;
        ...other equal lines
  &lt;/ItemWarehouseInfo&gt;
  </code></pre>