This class represents an XML document.
Object
XmlNode
XmlContainer
XmlDocument
[Visual Basic] Public Class XmlDocument Inherits XmlContainer [C#] public class XmlDocument : XmlContainer [C++] public __gc class XmlDocument : public XmlContainer [JScript] public class XmlDocument extends XmlContainer
To create an empty document, use one of the constructors of the class.
To create a document from an input stream, create an XmlTextReader and call the ReadDocument method.
To write a document to an output stream, create an XmlTextWriter and call the WriteDocument method.
Unlike the other XmlNode classes, an XmlDocument cannot be a child of another element. Any attempt to add an XmlDocument to the child list of an element causes an exception to be thrown.
A well-formed XML document must contain a single XmlElement node called the root element. The Root property may be used to access this element.
A well-formed XML document may additionally contain a single XmlHeader as the first child node, and any number of XmlComment, XmlPI, and whitespace-only XmlText nodes before and after the root element.
The XmlDocument class does not validate these well-formedness constraints as child nodes are added and removed. Validation does however occur when an XmlTextReader is used to read a document, or when an XmlTextWriter is used to write a document.
Namespace: System.Xml
Assembly: System.dll