Writing the XmlDocument


Writing the XmlDocument

Once you have built and modified your XmlDocument , you can save it to a stream through the Save method on the XmlDocument class. The Save method allows you to specify the destination by using the name of a file, a Stream object, a TextWriter object, or an XmlWriter object. It is important to note that all operations that execute on an XmlDocument are made on the in-memory node tree, and changes will not be persisted until the Save method is called. Listing 11.30 shows how an XmlDocument can be saved using each overload of the Save method.

Listing 11.30
 C# doc.Save("books.xml"); doc.Save(new FileStream("books.xml", FileMode.Open)); doc.Save(new StreamWriter("books.xml")); doc.Save(new XmlTextWriter("books.xml")); VB doc.Save("books.xml") doc.Save(New FileStream("books.xml", FileMode.Open)) doc.Save(New StreamWriter("books.xml")) doc.Save(New XmlTextWriter("books.xml")) 


Microsoft.NET Compact Framework Kick Start
Microsoft .NET Compact Framework Kick Start
ISBN: 0672325705
EAN: 2147483647
Year: 2003
Pages: 206

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net