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