O'Reilly logo

Microsoft® .NET Compact Framework Kick Start by Ronnie Yates, Erik Rubin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required