Mega Code Archive

 
Categories / C# / XML
 

Copy everything from the XPathNavigator to writer

using System; using System.IO; using System.Xml; using System.Xml.XPath; public class Sample {     public static void Main()     {         XPathDocument doc = new XPathDocument("books.xml");         XPathNavigator nav = doc.CreateNavigator();         XmlWriter writer = XmlWriter.Create(Console.Out);         writer.WriteStartElement("myBooks");         nav.MoveToChild("bookstore", "");         nav.MoveToChild("book", "");         writer.WriteNode(nav, false);         writer.WriteEndElement();         writer.Close();     } }