Closing an XMLDocument Object

Figure 1. Closing an XMLDocument
close();

Once you have finished adding data to an XML document, you need to close it. The close method of the XMLDocument class takes no parameters. Calling the close method will not close the output stream you specified as a parameter to the XML document. You must close this stream separately.

Once closed, a document will write all remaining XML information to the stream to complete a well formed XML document. If the document object is using an internal string stream buffer, you may save the document to the database or write it to another stream.