Mono Class Library: System.Xml Namespace

System.Xml.XmlDocument Class

The root node of an XML document. [Edit]

See Also: XmlDocument Members

System.Object
     System.Xml.XmlNode
          System.Xml.XmlDocument

public class XmlDocument : XmlNode, IHasXmlChildNode

Remarks

An Xml document is the root node of an Xml tree. The root node contains optional System.Xml.XmlDeclaration, zero or more System.Xml.XmlProcessingInstructions, zero or more System.Xml.XmlWhitespaces, zero or more System.Xml.XmlComments, optional System.Xml.XmlDocumentType which becomes the XmlDocument.DocumentType, and exactly one System.Xml.XmlElement which is the XmlDocument.DocumentElement.

Note that an XmlDocument is not same as the XmlDocument.DocumentElement. The document element is the top-level element node. An XmlDocument is not an element; it is the parent of the top-most element. Whereas all element nodes have parent nodes, XmlDocuments do not have parents.

Note that this class and the entire Document Object Model classes in this namespace is part of ECMA-335 CLI standard. Also note that there are many members which has corresponding interface member in any of W3C Document Object Model specifications.

XmlDocument provides a set of node editing event system. XmlDocument.NodeInserting, XmlDocument.NodeInserted, XmlDocument.NodeChanging, XmlDocument.NodeChanged, XmlDocument.NodeRemoving and XmlDocument.NodeRemoved are the events and all of them are typed as System.Xml.XmlNodeChangedEventHandler.

When a child node is being replaced, or the node being inserted is actually attached to another parent, then first XmlDocument.NodeRemoving is raised. However, when only the character data of a node is changed, then it just raises XmlDocument.NodeChanging and no insertion and removal events are raised.

For attribute nodes, the event system is more complicated. If an attribute is replacing another one, then first XmlDocument.NodeRemoving is raised. However, if XmlAttribute.Value is being set, then the behavior varies depending on how many children are under the attribute node. If there was nothing, then this NodeInserting event is raised. If there was only one System.Xml.XmlCharacterData child, then XmlDocument.NodeChanging is raised. In other cases, XmlDocument.NodeRemoving is raised for each existing child, and then this NodeInserting event is raised. Note that in that single character data child case, the target node of XmlDocument.NodeChanging and XmlDocument.NodeChanged events is not the attribute node, but the child character data node of the attribute.

[Edit]

Requirements

Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0