<p>What is the easiest way to merge XML from two distinct DOM Documents?  Is there a way other than using the Canonical <a href="http://support.microsoft.com/kb/311530" rel="nofollow noreferrer">DataReader</a> approach and then messing with the outputted DOM.  What I basically want is to AppendChild to XmlElements without getting: <code>The node to be inserted is from a different document context.</code>  Here is C# code that I want to work, that obviously won't (what I am doing is merging two documents which have bunch of nodes that I am interested in parts of):</p>

<pre><code>XmlDocument doc1 = new XmlDocument();
doc1.LoadXml("&lt;a&gt;&lt;items&gt;&lt;item1/&gt;&lt;item2/&gt;&lt;item3/&gt;&lt;/items&gt;&lt;/a&gt;");
XmlDocument doc2 = new XmlDocument();
doc2.LoadXml("&lt;b&gt;&lt;items&gt;&lt;item4/&gt;&lt;item5/&gt;&lt;item6/&gt;&lt;/items&gt;&lt;/b&gt;");

XmlNode doc2Node = doc2.SelectSingleNode("/b/items");

XmlNodeList doc1Nodes = doc1.SelectNodes("/a/items/*");

foreach (XmlNode doc1Node in doc1Nodes)
{
    doc2Node.AppendChild(doc1Node);
}
</code></pre>

[{'answer_id': 57593, 'author': 'ckarras', 'author_id': 5688, 'author_profile': 'https://Stackoverflow.com/users/5688', 'pm_score': 4, 'selected': True, 'text': '<p>You can use the XmlDocument.ImportNode method to copy a node from a XmlDocument to another.</p>\n'}, {'answer_id': 57602, 'author': 'VolkerK', 'author_id': 4833, 'author_profile': 'https://Stackoverflow.com/users/4833', 'pm_score': 1, 'selected': False, 'text': '<p>You might be interested in <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.importnode.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.importnode.aspx</a>. But take a close look at the "The following table describes the specific behavior for each XmlNodeType."-part of that document.</p>\n'}]
['https://Stackoverflow.com/questions/57577', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3798/']