16 December, 2009
0 Comments
0 categories
http://www.geekpedia.com/tutorial150_How-to-copy-XML-nodes-between-documents.html
To copy node between XmlDocuments use importnode:
// Store the root node of the destination document into an XmlNode
// The 1 in ChildNodes[1] is the index of the node to be copied (where 0 is the first node)
XmlNode rootDest = myDestDoc["DestinationRoot"];
// Store the node to be copied into an XmlNode
XmlNode nodeOrig = mySourceDoc["SourceRoot"].ChildNodes[1];
// Store the copy of the original node into an XmlNode
XmlNode nodeDest = myDestDoc.ImportNode(nodeOrig, true);
// Append the node being copied to the root of the destination document
rootDest.AppendChild(nodeDest);
Tags: C#XML - XSLT - XPath