When overridden in a derived class, closes any open elements or attributes and puts the writer back in the Start state.
Type Reason ArgumentException The current instance is in the wrong System.Xml.WriteState, or the document does not have a root element.
When you use the System.Xml.XmlWriter methods to output XML, the elements and attributes will not be written until you call the XmlWriter.Close method. For example, if you are using the XmlWriter to populate an System.Xml.XmlDocument, until you close the System.Xml.XmlWriter, you will not be able to observe the written elements and attributes in the target document.
For the asynchronous version of this method, see XmlWriter.WriteEndDocumentAsync.