title: What is the difference between Node.SelectNodes(/*) and Node.childNodes?
body: <pre><code>        string XML1 = "&lt;Root&gt;&lt;InsertHere&gt;&lt;/InsertHere&gt;&lt;/Root&gt;";
          string XML2 = "&lt;Root&gt;&lt;child1&gt;&lt;childnodes&gt;data&lt;/childnodes&gt;&lt;childnodes&gt;data1&lt;/childnodes&gt;&lt;/child1&gt;&lt;child2&gt;&lt;childnodes&gt;data&lt;/childnodes&gt;&lt;childnodes&gt;data1&lt;/childnodes&gt;&lt;/child2&gt;&lt;/Root&gt;";
  </code></pre>
  
  <p>Among below mentioned two code samples.. usage of childNodes doesn't copy all the child nodes from XML2. only <code>&lt;child1&gt;</code> is being copied.</p>
  
  <pre><code>        string strXpath = "/Root/InsertHere";
  
          XmlDocument xdxmlChildDoc = new XmlDocument();
          XmlDocument ParentDoc = new XmlDocument();
          ParentDoc.LoadXml(XML1);
          xdxmlChildDoc.LoadXml(XML2);
  
          XmlNode xnNewNode = ParentDoc.ImportNode(xdxmlChildDoc.DocumentElement.SelectSingleNode("/Root"), true);
  
          if (xnNewNode != null)
          {
              XmlNodeList xnChildNodes = xnNewNode.SelectNodes("/*");
              if (xnChildNodes != null)
              {
                  foreach (XmlNode xnNode in xnChildNodes)
                  {
                      if (xnNode != null)
                      {
                          ParentDoc.DocumentElement.SelectSingleNode(strXpath).AppendChild(xnNode);
                      }
                  }
              }
          }
  </code></pre>
  
  <p><strong>code2:</strong></p>
  
  <pre><code>    if (xnNewNode != null)
      {
          XmlNodeList xnChildNodes = xnNewNode.ChildNodes;
          if (xnChildNodes != null)
          {
              foreach (XmlNode xnNode in xnChildNodes)
              {
                  if (xnNode != null)
                  {
                      ParentDoc.DocumentElement.SelectSingleNode(strXpath).AppendChild(xnNode);
                  }
              }
          }
      }
  </code></pre>
  
  <p>ParentDoc.OuterXML after executing first sample of code:</p>
  
  <pre><code>&lt;Root&gt;
      &lt;InsertHere&gt;
          &lt;child1&gt;
              &lt;childnodes&gt;data&lt;/childnodes&gt;
              &lt;childnodes&gt;data1&lt;/childnodes&gt;
          &lt;/child1&gt;
          &lt;child2&gt;
              &lt;childnodes&gt;data&lt;/childnodes&gt;
              &lt;childnodes&gt;data1&lt;/childnodes&gt;
          &lt;/child2&gt;
      &lt;/InsertHere&gt;
  &lt;/Root&gt;
  </code></pre>
  
  <p>ParentDoc.OuterXML after executing second sample of Code</p>
  
  <pre><code>&lt;Root&gt;
      &lt;InsertHere&gt;
          &lt;child1&gt;
              &lt;childnodes&gt;data&lt;/childnodes&gt;
              &lt;childnodes&gt;data1&lt;/childnodes&gt;
          &lt;/child1&gt;
      &lt;/InsertHere&gt;
  &lt;/Root&gt;
  </code></pre>