.NET Framework Class Library
XmlDocument Class

Represents an XML document.

To browse the .NET Framework source code for this type, see the Reference Source.

Namespace:   System.Xml
Assembly:  System.Xml (in System.Xml.dll)
Syntax
Public Class XmlDocument _
	Inherits [%$TOPIC/6kza7w4k_en-us_VS_110_3_0_0_0_0%]
public class XmlDocument : [%$TOPIC/6kza7w4k_en-us_VS_110_3_0_1_0_0%]
public ref class XmlDocument : public [%$TOPIC/6kza7w4k_en-us_VS_110_3_0_2_0_0%]
type XmlDocument =  
    class 
        inherit [%$TOPIC/6kza7w4k_en-us_VS_110_3_0_3_0_0%] 
    end

The XmlDocument type exposes the following members.

Constructors
  NameDescription
Public method Supported by the XNA Framework XmlDocumentInitializes a new instance of the XmlDocument class.
Protected method Supported by the XNA Framework XmlDocument(XmlImplementation)Initializes a new instance of the XmlDocument class with the specified XmlImplementation.
Public method Supported by the XNA Framework XmlDocument(XmlNameTable)Initializes a new instance of the XmlDocument class with the specified XmlNameTable.
Top
Properties
  NameDescription
Public property Supported by the XNA Framework AttributesGets an XmlAttributeCollection containing the attributes of this node. (Inherited from XmlNode.)
Public property Supported by the XNA Framework BaseURIGets the base URI of the current node. (Overrides XmlNodeBaseURI.)
Public property Supported by the XNA Framework ChildNodesGets all the child nodes of the node. (Inherited from XmlNode.)
Public property Supported by the XNA Framework DocumentElementGets the root XmlElement for the document.
Public property DocumentTypeGets the node containing the DOCTYPE declaration.
Public property Supported by the XNA Framework FirstChildGets the first child of the node. (Inherited from XmlNode.)
Public property Supported by the XNA Framework HasChildNodesGets a value indicating whether this node has any child nodes. (Inherited from XmlNode.)
Public property Supported by the XNA Framework ImplementationGets the XmlImplementation object for the current document.
Public property Supported by the XNA Framework InnerTextThrows an InvalidOperationException in all cases. (Overrides XmlNodeInnerText.)

In XNA Framework 3.0, this member is inherited from XmlNode InnerText.
Public property Supported by the XNA Framework InnerXmlGets or sets the markup representing the children of the current node. (Overrides XmlNodeInnerXml.)
Public property Supported by the XNA Framework IsReadOnlyGets a value indicating whether the current node is read-only. (Overrides XmlNodeIsReadOnly.)
Public property Supported by the XNA Framework ItemStringGets the first child element with the specified Name. (Inherited from XmlNode.)
Public property Supported by the XNA Framework ItemString, StringGets the first child element with the specified LocalName and NamespaceURI. (Inherited from XmlNode.)
Public property Supported by the XNA Framework LastChildGets the last child of the node. (Inherited from XmlNode.)
Public property Supported by the XNA Framework LocalNameGets the local name of the node. (Overrides XmlNodeLocalName.)
Public property Supported by the XNA Framework NameGets the qualified name of the node. (Overrides XmlNodeName.)
Public property Supported by the XNA Framework NamespaceURIGets the namespace URI of this node. (Inherited from XmlNode.)
Public property Supported by the XNA Framework NameTableGets the XmlNameTable associated with this implementation.
Public property Supported by the XNA Framework NextSiblingGets the node immediately following this node. (Inherited from XmlNode.)
Public property Supported by the XNA Framework NodeTypeGets the type of the current node. (Overrides XmlNodeNodeType.)
Public property Supported by the XNA Framework OuterXmlGets the markup containing this node and all its child nodes. (Inherited from XmlNode.)
Public property Supported by the XNA Framework OwnerDocumentGets the XmlDocument to which the current node belongs. (Overrides XmlNodeOwnerDocument.)
Public property Supported by the XNA Framework ParentNodeGets the parent node of this node (for nodes that can have parents). (Overrides XmlNodeParentNode.)
Public property Supported by the XNA Framework PrefixGets or sets the namespace prefix of this node. (Inherited from XmlNode.)
Public property Supported by the XNA Framework PreserveWhitespaceGets or sets a value indicating whether to preserve white space in element content.
Public property Supported by the XNA Framework PreviousSiblingGets the node immediately preceding this node. (Inherited from XmlNode.)
Public property Supported by the XNA Framework SchemaInfoReturns the Post-Schema-Validation-Infoset (PSVI) of the node. (Overrides XmlNodeSchemaInfo.)
Public property Supported by the XNA Framework SchemasGets or sets the XmlSchemaSet object associated with this XmlDocument.
Public property Supported by the XNA Framework ValueGets or sets the value of the node. (Inherited from XmlNode.)
Public property Supported by the XNA Framework XmlResolverSets the XmlResolver to use for resolving external resources.
Top
Methods
  NameDescription
Public method Supported by the XNA Framework AppendChildAdds the specified node to the end of the list of child nodes, of this node. (Inherited from XmlNode.)
Public method Supported by the XNA Framework CloneCreates a duplicate of this node. (Inherited from XmlNode.)
Public method Supported by the XNA Framework CloneNodeCreates a duplicate of this node. (Overrides XmlNodeCloneNode(Boolean).)
Public method Supported by the XNA Framework CreateAttribute(String)Creates an XmlAttribute with the specified Name.
Public method Supported by the XNA Framework CreateAttribute(String, String)Creates an XmlAttribute with the specified qualified name and NamespaceURI.
Public method Supported by the XNA Framework CreateAttribute(String, String, String)Creates an XmlAttribute with the specified Prefix, LocalName, and NamespaceURI.
Public method Supported by the XNA Framework CreateCDataSectionCreates an XmlCDataSection containing the specified data.
Public method Supported by the XNA Framework CreateCommentCreates an XmlComment containing the specified data.
Protected method Supported by the XNA Framework CreateDefaultAttributeCreates a default attribute with the specified prefix, local name and namespace URI.
Public method Supported by the XNA Framework CreateDocumentFragmentCreates an XmlDocumentFragment.
Public method CreateDocumentTypeReturns a new XmlDocumentType object.
Public method Supported by the XNA Framework CreateElement(String)Creates an element with the specified name.
Public method Supported by the XNA Framework CreateElement(String, String)Creates an XmlElement with the qualified name and NamespaceURI.
Public method Supported by the XNA Framework CreateElement(String, String, String)Creates an element with the specified Prefix, LocalName, and NamespaceURI.
Public method Supported by the XNA Framework CreateEntityReferenceCreates an XmlEntityReference with the specified name.
Public method CreateNavigatorCreates a new XPathNavigator object for navigating this document. (Overrides XmlNodeCreateNavigator.)
Protected method CreateNavigator(XmlNode)Creates an XPathNavigator object for navigating this document positioned on the XmlNode specified.
Public method Supported by the XNA Framework CreateNode(String, String, String)Creates an XmlNode with the specified node type, Name, and NamespaceURI.
Public method Supported by the XNA Framework CreateNode(XmlNodeType, String, String)Creates an XmlNode with the specified XmlNodeType, Name, and NamespaceURI.
Public method Supported by the XNA Framework CreateNode(XmlNodeType, String, String, String)Creates a XmlNode with the specified XmlNodeType, Prefix, Name, and NamespaceURI.
Public method Supported by the XNA Framework CreateProcessingInstructionCreates an XmlProcessingInstruction with the specified name and data.
Public method Supported by the XNA Framework CreateSignificantWhitespaceCreates an XmlSignificantWhitespace node.
Public method Supported by the XNA Framework CreateTextNodeCreates an XmlText with the specified text.
Public method Supported by the XNA Framework CreateWhitespaceCreates an XmlWhitespace node.
Public method Supported by the XNA Framework CreateXmlDeclarationCreates an XmlDeclaration node with the specified values.
Public method Supported by the XNA Framework Equals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected method Supported by the XNA Framework FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetElementByIdGets the XmlElement with the specified ID.
Public method Supported by the XNA Framework GetElementsByTagName(String)Returns an XmlNodeList containing a list of all descendant elements that match the specified Name.
Public method Supported by the XNA Framework GetElementsByTagName(String, String)Returns an XmlNodeList containing a list of all descendant elements that match the specified LocalName and NamespaceURI.
Public method Supported by the XNA Framework GetEnumeratorGet an enumerator that iterates through the child nodes in the current node. (Inherited from XmlNode.)
Public method Supported by the XNA Framework GetHashCodeServes as the default hash function. (Inherited from Object.)
Public method Supported by the XNA Framework GetNamespaceOfPrefixLooks up the closest xmlns declaration for the given prefix that is in scope for the current node and returns the namespace URI in the declaration. (Inherited from XmlNode.)
Public method Supported by the XNA Framework GetPrefixOfNamespaceLooks up the closest xmlns declaration for the given namespace URI that is in scope for the current node and returns the prefix defined in that declaration. (Inherited from XmlNode.)
Public method Supported by the XNA Framework GetTypeGets the Type of the current instance. (Inherited from Object.)
Public method Supported by the XNA Framework ImportNodeImports a node from another document to the current document.
Public method Supported by the XNA Framework InsertAfterInserts the specified node immediately after the specified reference node. (Inherited from XmlNode.)
Public method Supported by the XNA Framework InsertBeforeInserts the specified node immediately before the specified reference node. (Inherited from XmlNode.)
Public method Supported by the XNA Framework Load(Stream)Loads the XML document from the specified stream.
Public method Supported by the XNA Framework Load(String)Loads the XML document from the specified URL.
Public method Supported by the XNA Framework Load(TextReader)Loads the XML document from the specified TextReader.
Public method Supported by the XNA Framework Load(XmlReader)Loads the XML document from the specified XmlReader.
Public method Supported by the XNA Framework LoadXmlLoads the XML document from the specified string.
Protected method Supported by the XNA Framework MemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public method Supported by the XNA Framework NormalizePuts all XmlText nodes in the full depth of the sub-tree underneath this XmlNode into a "normal" form where only markup (that is, tags, comments, processing instructions, CDATA sections, and entity references) separates XmlText nodes, that is, there are no adjacent XmlText nodes. (Inherited from XmlNode.)
Public method Supported by the XNA Framework PrependChildAdds the specified node to the beginning of the list of child nodes for this node. (Inherited from XmlNode.)
Public method Supported by the XNA Framework ReadNodeCreates an XmlNode object based on the information in the XmlReader. The reader must be positioned on a node or attribute.
Public method Supported by the XNA Framework RemoveAllRemoves all the child nodes and/or attributes of the current node. (Inherited from XmlNode.)
Public method Supported by the XNA Framework RemoveChildRemoves specified child node. (Inherited from XmlNode.)
Public method Supported by the XNA Framework ReplaceChildReplaces the child node oldChild with newChild node. (Inherited from XmlNode.)
Public method Supported by the XNA Framework Save(Stream)Saves the XML document to the specified stream.
Public method Supported by the XNA Framework Save(String)Saves the XML document to the specified file. If the specified file exists, this method overwrites it.
Public method Supported by the XNA Framework Save(TextWriter)Saves the XML document to the specified TextWriter.
Public method Supported by the XNA Framework Save(XmlWriter)Saves the XML document to the specified XmlWriter.
Public method Supported by the XNA Framework SelectNodes(String)Selects a list of nodes matching the XPath expression. (Inherited from XmlNode.)
Public method Supported by the XNA Framework SelectNodes(String, XmlNamespaceManager)Selects a list of nodes matching the XPath expression. Any prefixes found in the XPath expression are resolved using the supplied XmlNamespaceManager. (Inherited from XmlNode.)
Public method Supported by the XNA Framework SelectSingleNode(String)Selects the first XmlNode that matches the XPath expression. (Inherited from XmlNode.)
Public method Supported by the XNA Framework SelectSingleNode(String, XmlNamespaceManager)Selects the first XmlNode that matches the XPath expression. Any prefixes found in the XPath expression are resolved using the supplied XmlNamespaceManager. (Inherited from XmlNode.)
Public method Supported by the XNA Framework SupportsTests if the DOM implementation implements a specific feature. (Inherited from XmlNode.)
Public method Supported by the XNA Framework ToStringReturns a string that represents the current object. (Inherited from Object.)
Public method Supported by the XNA Framework Validate(ValidationEventHandler)Validates the XmlDocument against the XML Schema Definition Language (XSD) schemas contained in the Schemas property.
Public method Supported by the XNA Framework Validate(ValidationEventHandler, XmlNode)Validates the XmlNode object specified against the XML Schema Definition Language (XSD) schemas in the Schemas property.
Public method Supported by the XNA Framework WriteContentToSaves all the children of the XmlDocument node to the specified XmlWriter. (Overrides XmlNodeWriteContentTo(XmlWriter).)
Public method Supported by the XNA Framework WriteToSaves the XmlDocument node to the specified XmlWriter. (Overrides XmlNodeWriteTo(XmlWriter).)
Top
Events
  NameDescription
Public event Supported by the XNA Framework NodeChangedOccurs when the Value of a node belonging to this document has been changed.
Public event Supported by the XNA Framework NodeChangingOccurs when the Value of a node belonging to this document is about to be changed.
Public event Supported by the XNA Framework NodeInsertedOccurs when a node belonging to this document has been inserted into another node.
Public event Supported by the XNA Framework NodeInsertingOccurs when a node belonging to this document is about to be inserted into another node.
Public event Supported by the XNA Framework NodeRemovedOccurs when a node belonging to this document has been removed from its parent.
Public event Supported by the XNA Framework NodeRemovingOccurs when a node belonging to this document is about to be removed from the document.
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implemetation Private method Supported by the XNA Framework ICloneableCloneFor a description of this member, see XmlNodeClone. (Inherited from XmlNode.)
Explicit interface implemetation Private method Supported by the XNA Framework IEnumerableGetEnumeratorFor a description of this member, see XmlNodeGetEnumerator. (Inherited from XmlNode.)
Top
Remarks
NoteNote

To view the .NET Framework source code for this type, see the Reference Source. You can browse through the source code online, download the reference for offline viewing, and step through the sources (including patches and updates) during debugging; see instructions.

This class implements the W3C Document Object Model (DOM) Level 1 Core and the Core DOM Level 2. The DOM is an in-memory (cache) tree representation of an XML document and enables the navigation and editing of this document. Because XmlDocument implements the IXPathNavigable interface it can also be used as the source document for the XslTransform class.

The XmlDataDocument class extends XmlDocument and allows structured data to be stored, retrieved, and manipulated through a relational DataSet. This class allows components to mix XML and relational views of the underlying data.

For more information, see XML Document Object Model (DOM).

Security noteSecurity Note

Exceptions raised as a result of using the XmlDocument class, such as the XmlException class may contain sensitive information that should not be exposed in untrusted scenarios. Exceptions should be properly handled so that this sensitive information is not exposed in untrusted scenarios.

Version Information

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.