Mega Code Archive

 
Categories / C# Tutorial / XML
 

Copy one xml document as a sub element into another xml document

using System; using System.Xml; class MainClass {     static void Main(string[] args)     {         XmlTextWriter writer = new XmlTextWriter("C:\\xmlWriterTest.xml", null);         writer.WriteStartDocument();         XmlTextReader reader = new XmlTextReader(@"C:\Sample.xml");                  while (!reader.EOF)         {             writer.WriteNode(reader, false);         }         // Ends the document.         writer.WriteEndDocument();         writer.Close();         return;     } }