dotnetnoob wrote:
i need to copy the content of a xml document and use it as xml element and
insert into another xml document.
Can someone tell me how?
One way using the DOM/XmlDocument:
XmlDocument xmlDocument1 = new XmlDocument();
xmlDocument1.Load("file1.xml");
XmlDocument xmlDocument2 = new XmlDocument();
xmlDocument2.Load("file2.xml");
xmlDocument1.DocumentElement.AppendChild(xmlDocume nt1.ImportNode(xmlDocument2.DocumentElement,
true));
xmlDocument1.Save("file3.xml");
// of course you can also overwrite the existing document with e.g.
// xmlDocument1.Save("file1.xml");
Should also be possible using XmlReader and XmlWriter but needs more code.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/