title: how to replace xml elements with another xml elements in c#?
body: <p>This is my two xml document.</p>
  
  <p>This xml is stored in paraouterXml string.</p>
  
  <pre><code>&lt;w:tbl&gt;
   &lt;w:tblPr&gt;
   &lt;/w:tblPr&gt;
   &lt;w:tblGrid&gt;
   &lt;/w:tblGrid&gt;
  &lt;/w:tbl&gt;
  </code></pre>
  
  <p>This xml is stored in tblMetaInfo string.</p>
  
  <pre><code>&lt;root&gt;
   &lt;w:tblPr&gt;
    &lt;w:tblStyle w:val="TableGrid" /&gt; 
    &lt;w:tblW w:w="0" w:type="auto" /&gt; 
    &lt;w:tblLook w:val="04A0" /&gt; 
    &lt;/w:tblPr&gt;
   &lt;w:tblGrid&gt;
    &lt;w:gridCol w:w="1947" /&gt; 
    &lt;w:gridCol w:w="1947" /&gt; 
    &lt;/w:tblGrid&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>So,here i want to replace paraouterXml's <code>&lt;w:tblPr&gt;,&lt;w:tblGrid&gt;</code> with tblMetaInfo's <code>&lt;w:tblPr&gt;,&lt;w:tblGrid&gt;</code> elements.</p>
  
  <p>This is c# code...</p>
  
  <pre><code>XmlDocument xDoc = new XmlDocument();
  xDoc.LoadXml(table.OuterXml);
  XmlNode newNode = xDoc.DocumentElement;
  
  XmlNodeList tblPrNode = xDoc.GetElementsByTagName("w:tblPr");
  tblPrNode[0].RemoveAll();
  XmlNodeList tblGridNode = xDoc.GetElementsByTagName("w:tblGrid");
  tblGridNode[0].RemoveAll();
  
  XmlDocument xDoc1 = new XmlDocument();
  xDoc1.LoadXml(tblMetaInfo);
  XmlNode newNode1 = xDoc1.DocumentElement;
  XmlNodeList tblPrNode1 = xDoc1.GetElementsByTagName("w:tblPr");
  XmlNodeList tblGridNode1 = xDoc1.GetElementsByTagName("w:tblGrid");
  
  tblPrNode[0].ReplaceChild(tblPrNode1[0], tblPrNode[0]);
  tblGridNode[0].ReplaceChild(tblGridNode1[0], tblGridNode[0]);
  </code></pre>
  
  <p>But it throwing some error...</p>
  
  <p>Please guide me to get out of this issue...</p>