mscorlib(4.0.0.0) API with additions
System.Xml.XmlDocument Class Reference

Represents an XML document. You can use this class to load, validate, edit, add, and position XML in a document. More...

Inheritance diagram for System.Xml.XmlDocument:
[legend]
Collaboration diagram for System.Xml.XmlDocument:
[legend]

Public Member Functions

 XmlDocument ()
 Initializes a new instance of the T:System.Xml.XmlDocument class. More...
 
 XmlDocument (XmlNameTable nt)
 Initializes a new instance of the XmlDocument class with the specified T:System.Xml.XmlNameTable. More...
 
override XmlNode CloneNode (bool deep)
 Creates a duplicate of this node. More...
 
XmlAttribute CreateAttribute (string name)
 Creates an T:System.Xml.XmlAttribute with the specified P:System.Xml.XmlDocument.Name. More...
 
virtual XmlCDataSection CreateCDataSection (string data)
 Creates an T:System.Xml.XmlCDataSection containing the specified data. More...
 
virtual XmlComment CreateComment (string data)
 Creates an T:System.Xml.XmlComment containing the specified data. More...
 
virtual XmlDocumentType CreateDocumentType (string name, string publicId, string systemId, string internalSubset)
 Returns a new T:System.Xml.XmlDocumentType object. More...
 
virtual XmlDocumentFragment CreateDocumentFragment ()
 Creates an T:System.Xml.XmlDocumentFragment. More...
 
XmlElement CreateElement (string name)
 Creates an element with the specified name. More...
 
virtual XmlEntityReference CreateEntityReference (string name)
 Creates an T:System.Xml.XmlEntityReference with the specified name. More...
 
virtual XmlProcessingInstruction CreateProcessingInstruction (string target, string data)
 Creates an T:System.Xml.XmlProcessingInstruction with the specified name and data. More...
 
virtual XmlDeclaration CreateXmlDeclaration (string version, string encoding, string standalone)
 Creates an T:System.Xml.XmlDeclaration node with the specified values. More...
 
virtual XmlText CreateTextNode (string text)
 Creates an T:System.Xml.XmlText with the specified text. More...
 
virtual XmlSignificantWhitespace CreateSignificantWhitespace (string text)
 Creates an T:System.Xml.XmlSignificantWhitespace node. More...
 
override XPathNavigator CreateNavigator ()
 Creates a new T:System.Xml.XPath.XPathNavigator object for navigating this document. More...
 
virtual XmlWhitespace CreateWhitespace (string text)
 Creates an T:System.Xml.XmlWhitespace node. More...
 
virtual XmlNodeList GetElementsByTagName (string name)
 Returns an T:System.Xml.XmlNodeList containing a list of all descendant elements that match the specified P:System.Xml.XmlDocument.Name. More...
 
XmlAttribute CreateAttribute (string qualifiedName, string namespaceURI)
 Creates an T:System.Xml.XmlAttribute with the specified qualified name and P:System.Xml.XmlNode.NamespaceURI. More...
 
XmlElement CreateElement (string qualifiedName, string namespaceURI)
 Creates an T:System.Xml.XmlElement with the qualified name and P:System.Xml.XmlNode.NamespaceURI. More...
 
virtual XmlNodeList GetElementsByTagName (string localName, string namespaceURI)
 Returns an T:System.Xml.XmlNodeList containing a list of all descendant elements that match the specified P:System.Xml.XmlDocument.LocalName and P:System.Xml.XmlNode.NamespaceURI. More...
 
virtual XmlElement GetElementById (string elementId)
 Gets the T:System.Xml.XmlElement with the specified ID. More...
 
virtual XmlNode ImportNode (XmlNode node, bool deep)
 Imports a node from another document to the current document. More...
 
virtual XmlAttribute CreateAttribute (string prefix, string localName, string namespaceURI)
 Creates an T:System.Xml.XmlAttribute with the specified P:System.Xml.XmlNode.Prefix, P:System.Xml.XmlDocument.LocalName, and P:System.Xml.XmlNode.NamespaceURI. More...
 
virtual XmlElement CreateElement (string prefix, string localName, string namespaceURI)
 Creates an element with the specified P:System.Xml.XmlNode.Prefix, P:System.Xml.XmlDocument.LocalName, and P:System.Xml.XmlNode.NamespaceURI. More...
 
virtual XmlNode CreateNode (XmlNodeType type, string prefix, string name, string namespaceURI)
 Creates a T:System.Xml.XmlNode with the specified T:System.Xml.XmlNodeType, P:System.Xml.XmlNode.Prefix, P:System.Xml.XmlDocument.Name, and P:System.Xml.XmlNode.NamespaceURI. More...
 
virtual XmlNode CreateNode (string nodeTypeString, string name, string namespaceURI)
 Creates an T:System.Xml.XmlNode with the specified node type, P:System.Xml.XmlDocument.Name, and P:System.Xml.XmlNode.NamespaceURI. More...
 
virtual XmlNode CreateNode (XmlNodeType type, string name, string namespaceURI)
 Creates an T:System.Xml.XmlNode with the specified T:System.Xml.XmlNodeType, P:System.Xml.XmlDocument.Name, and P:System.Xml.XmlNode.NamespaceURI. More...
 
virtual XmlNode ReadNode (XmlReader reader)
 Creates an T:System.Xml.XmlNode object based on the information in the T:System.Xml.XmlReader. The reader must be positioned on a node or attribute. More...
 
virtual void Load (string filename)
 Loads the XML document from the specified URL. More...
 
virtual void Load (Stream inStream)
 Loads the XML document from the specified stream. More...
 
virtual void Load (TextReader txtReader)
 Loads the XML document from the specified T:System.IO.TextReader. More...
 
virtual void Load (XmlReader reader)
 Loads the XML document from the specified T:System.Xml.XmlReader. More...
 
virtual void LoadXml (string xml)
 Loads the XML document from the specified string. More...
 
virtual void Save (string filename)
 Saves the XML document to the specified file. If the specified file exists, this method overwrites it. More...
 
virtual void Save (Stream outStream)
 Saves the XML document to the specified stream. More...
 
virtual void Save (TextWriter writer)
 Saves the XML document to the specified T:System.IO.TextWriter. More...
 
virtual void Save (XmlWriter w)
 Saves the XML document to the specified T:System.Xml.XmlWriter. More...
 
override void WriteTo (XmlWriter w)
 Saves the XmlDocument node to the specified T:System.Xml.XmlWriter. More...
 
override void WriteContentTo (XmlWriter xw)
 Saves all the children of the XmlDocument node to the specified T:System.Xml.XmlWriter. More...
 
void Validate (ValidationEventHandler validationEventHandler)
 Validates the T:System.Xml.XmlDocument against the XML Schema Definition Language (XSD) schemas contained in the P:System.Xml.XmlDocument.Schemas property. More...
 
void Validate (ValidationEventHandler validationEventHandler, XmlNode nodeToValidate)
 Validates the T:System.Xml.XmlNode object specified against the XML Schema Definition Language (XSD) schemas in the P:System.Xml.XmlDocument.Schemas property. More...
 
- Public Member Functions inherited from System.Xml.XmlNode
XmlNode SelectSingleNode (string xpath)
 Selects the first XmlNode that matches the XPath expression. More...
 
XmlNode SelectSingleNode (string xpath, XmlNamespaceManager nsmgr)
 Selects the first XmlNode that matches the XPath expression. Any prefixes found in the XPath expression are resolved using the supplied T:System.Xml.XmlNamespaceManager. More...
 
XmlNodeList SelectNodes (string xpath)
 Selects a list of nodes matching the XPath expression. More...
 
XmlNodeList SelectNodes (string xpath, XmlNamespaceManager nsmgr)
 Selects a list of nodes matching the XPath expression. Any prefixes found in the XPath expression are resolved using the supplied T:System.Xml.XmlNamespaceManager. More...
 
virtual XmlNode InsertBefore (XmlNode newChild, XmlNode refChild)
 Inserts the specified node immediately before the specified reference node. More...
 
virtual XmlNode InsertAfter (XmlNode newChild, XmlNode refChild)
 Inserts the specified node immediately after the specified reference node. More...
 
virtual XmlNode ReplaceChild (XmlNode newChild, XmlNode oldChild)
 Replaces the child node oldChild with newChild node. More...
 
virtual XmlNode RemoveChild (XmlNode oldChild)
 Removes specified child node. More...
 
virtual XmlNode PrependChild (XmlNode newChild)
 Adds the specified node to the beginning of the list of child nodes for this node. More...
 
virtual XmlNode AppendChild (XmlNode newChild)
 Adds the specified node to the end of the list of child nodes, of this node. More...
 
virtual void Normalize ()
 Puts 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. More...
 
virtual bool Supports (string feature, string version)
 Tests if the DOM implementation implements a specific feature. More...
 
virtual XmlNode Clone ()
 Creates a duplicate of this node. More...
 
IEnumerator GetEnumerator ()
 Get an enumerator that iterates through the child nodes in the current node. More...
 
virtual void RemoveAll ()
 Removes all the child nodes and/or attributes of the current node. More...
 
virtual string GetNamespaceOfPrefix (string prefix)
 Looks 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. More...
 
virtual string GetPrefixOfNamespace (string namespaceURI)
 Looks 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. More...
 

Public Attributes

override XmlNodeType NodeType => XmlNodeType.Document
 Gets the type of the current node. More...
 
override XmlNode ParentNode => null
 Gets the parent node of this node (for nodes that can have parents). More...
 
virtual XmlDocumentType DocumentType => (XmlDocumentType)FindChild(XmlNodeType.DocumentType)
 Gets the node containing the DOCTYPE declaration. More...
 
XmlImplementation Implementation => implementation
 Gets the T:System.Xml.XmlImplementation object for the current document. More...
 
override string Name => strDocumentName
 Gets the qualified name of the node. More...
 
override string LocalName => strDocumentName
 Gets the local name of the node. More...
 
XmlElement DocumentElement => (XmlElement)FindChild(XmlNodeType.Element)
 Gets the root T:System.Xml.XmlElement for the document. More...
 
override XmlDocument OwnerDocument => null
 Gets the T:System.Xml.XmlDocument to which the current node belongs. More...
 
XmlNameTable NameTable => implementation.NameTable
 Gets the T:System.Xml.XmlNameTable associated with this implementation. More...
 
override bool IsReadOnly => false
 Gets a value indicating whether the current node is read-only. More...
 
override string BaseURI => baseURI
 Gets the base URI of the current node. More...
 
- Public Attributes inherited from System.Xml.XmlNode
virtual XmlNodeList ChildNodes => new XmlChildNodes(this)
 Gets all the child nodes of the node. More...
 
virtual XmlNode PreviousSibling => null
 Gets the node immediately preceding this node. More...
 
virtual XmlNode NextSibling => null
 Gets the node immediately following this node. More...
 
virtual XmlAttributeCollection Attributes => null
 Gets an T:System.Xml.XmlAttributeCollection containing the attributes of this node. More...
 
virtual XmlNode FirstChild => LastNode?.next
 Gets the first child of the node. More...
 
virtual XmlNode LastChild => LastNode
 Gets the last child of the node. More...
 
virtual bool HasChildNodes => LastNode != null
 Gets a value indicating whether this node has any child nodes. More...
 
virtual string NamespaceURI => string.Empty
 Gets the namespace URI of this node. More...
 
virtual IXmlSchemaInfo SchemaInfo => XmlDocument.NotKnownSchemaInfo
 Gets the post schema validation infoset that has been assigned to this node as a result of schema validation. More...
 
virtual XmlNode PreviousText => null
 Gets the text node that immediately precedes this node. More...
 

Protected Member Functions

internal XmlDocument (XmlImplementation imp)
 Initializes a new instance of the XmlDocument class with the specified T:System.Xml.XmlImplementation. More...
 
virtual internal XPathNavigator CreateNavigator (XmlNode node)
 Creates an T:System.Xml.XPath.XPathNavigator object for navigating this document positioned on the T:System.Xml.XmlNode specified. More...
 
virtual internal XmlAttribute CreateDefaultAttribute (string prefix, string localName, string namespaceURI)
 Creates a default attribute with the specified prefix, local name and namespace URI. More...
 

Properties

XmlSchemaSet Schemas [get, set]
 Gets or sets the T:System.Xml.Schema.XmlSchemaSet object associated with this T:System.Xml.XmlDocument. More...
 
virtual XmlResolver XmlResolver [set]
 Sets the T:System.Xml.XmlResolver to use for resolving external resources. More...
 
bool PreserveWhitespace [get, set]
 Gets or sets a value indicating whether to preserve white space in element content. More...
 
override string InnerText [set]
 Throws an T:System.InvalidOperationException in all cases. More...
 
override string InnerXml [get, set]
 Gets or sets the markup representing the children of the current node. More...
 
override IXmlSchemaInfo SchemaInfo [get]
 Returns the Post-Schema-Validation-Infoset (PSVI) of the node. More...
 
XmlNodeChangedEventHandler NodeInserting
 Occurs when a node belonging to this document is about to be inserted into another node. More...
 
XmlNodeChangedEventHandler NodeInserted
 Occurs when a node belonging to this document has been inserted into another node. More...
 
XmlNodeChangedEventHandler NodeRemoving
 Occurs when a node belonging to this document is about to be removed from the document. More...
 
XmlNodeChangedEventHandler NodeRemoved
 Occurs when a node belonging to this document has been removed from its parent. More...
 
XmlNodeChangedEventHandler NodeChanging
 Occurs when the P:System.Xml.XmlNode.Value of a node belonging to this document is about to be changed. More...
 
XmlNodeChangedEventHandler NodeChanged
 Occurs when the P:System.Xml.XmlNode.Value of a node belonging to this document has been changed. More...
 
- Properties inherited from System.Xml.XmlNode
abstract string Name [get]
 Gets the qualified name of the node, when overridden in a derived class. More...
 
virtual string Value [get, set]
 Gets or sets the value of the node. More...
 
abstract XmlNodeType NodeType [get]
 Gets the type of the current node, when overridden in a derived class. More...
 
virtual XmlNode ParentNode [get]
 Gets the parent of this node (for nodes that can have parents). More...
 
virtual XmlDocument OwnerDocument [get]
 Gets the T:System.Xml.XmlDocument to which this node belongs. More...
 
virtual string Prefix [get, set]
 Gets or sets the namespace prefix of this node. More...
 
abstract string LocalName [get]
 Gets the local name of the node, when overridden in a derived class. More...
 
virtual bool IsReadOnly [get]
 Gets a value indicating whether the node is read-only. More...
 
virtual string InnerText [get, set]
 Gets or sets the concatenated values of the node and all its child nodes. More...
 
virtual string OuterXml [get]
 Gets the markup containing this node and all its child nodes. More...
 
virtual string InnerXml [get, set]
 Gets or sets the markup representing only the child nodes of this node. More...
 
virtual string BaseURI [get]
 Gets the base URI of the current node. More...
 
virtual XmlElement this[string name] [get]
 Gets the first child element with the specified P:System.Xml.XmlNode.Name. More...
 
virtual XmlElement this[string localname, string ns] [get]
 Gets the first child element with the specified P:System.Xml.XmlNode.LocalName and P:System.Xml.XmlNode.NamespaceURI. More...
 

Detailed Description

Represents an XML document. You can use this class to load, validate, edit, add, and position XML in a document.

Definition at line 13 of file XmlDocument.cs.

Constructor & Destructor Documentation

◆ XmlDocument() [1/3]

System.Xml.XmlDocument.XmlDocument ( )

Initializes a new instance of the T:System.Xml.XmlDocument class.

Definition at line 465 of file XmlDocument.cs.

◆ XmlDocument() [2/3]

System.Xml.XmlDocument.XmlDocument ( XmlNameTable  nt)

Initializes a new instance of the XmlDocument class with the specified T:System.Xml.XmlNameTable.

Parameters
ntThe XmlNameTable to use.

Definition at line 472 of file XmlDocument.cs.

◆ XmlDocument() [3/3]

internal System.Xml.XmlDocument.XmlDocument ( XmlImplementation  imp)
protected

Initializes a new instance of the XmlDocument class with the specified T:System.Xml.XmlImplementation.

Parameters
impThe XmlImplementation to use.

Definition at line 479 of file XmlDocument.cs.

Member Function Documentation

◆ CloneNode()

override XmlNode System.Xml.XmlDocument.CloneNode ( bool  deep)
virtual

Creates a duplicate of this node.

Parameters
deeptrue to recursively clone the subtree under the specified node; false to clone only the node itself.
Returns
The cloned XmlDocument node.

Implements System.Xml.XmlNode.

Definition at line 638 of file XmlDocument.cs.

◆ CreateAttribute() [1/3]

XmlAttribute System.Xml.XmlDocument.CreateAttribute ( string  name)

Creates an T:System.Xml.XmlAttribute with the specified P:System.Xml.XmlDocument.Name.

Parameters
nameThe qualified name of the attribute. If the name contains a colon, the P:System.Xml.XmlNode.Prefix property reflects the part of the name preceding the first colon and the P:System.Xml.XmlDocument.LocalName property reflects the part of the name following the first colon. The P:System.Xml.XmlNode.NamespaceURI remains empty unless the prefix is a recognized built-in prefix such as xmlns. In this case NamespaceURI has a value of http://www.w3.org/2000/xmlns/.
Returns
The new XmlAttribute.

Definition at line 786 of file XmlDocument.cs.

◆ CreateAttribute() [2/3]

XmlAttribute System.Xml.XmlDocument.CreateAttribute ( string  qualifiedName,
string  namespaceURI 
)

Creates an T:System.Xml.XmlAttribute with the specified qualified name and P:System.Xml.XmlNode.NamespaceURI.

Parameters
qualifiedNameThe qualified name of the attribute. If the name contains a colon then the P:System.Xml.XmlNode.Prefix property will reflect the part of the name preceding the colon and the P:System.Xml.XmlDocument.LocalName property will reflect the part of the name after the colon.
namespaceURIThe namespaceURI of the attribute. If the qualified name includes a prefix of xmlns, then this parameter must be http://www.w3.org/2000/xmlns/.
Returns
The new XmlAttribute.

Definition at line 1098 of file XmlDocument.cs.

◆ CreateAttribute() [3/3]

virtual XmlAttribute System.Xml.XmlDocument.CreateAttribute ( string  prefix,
string  localName,
string  namespaceURI 
)
virtual

Creates an T:System.Xml.XmlAttribute with the specified P:System.Xml.XmlNode.Prefix, P:System.Xml.XmlDocument.LocalName, and P:System.Xml.XmlNode.NamespaceURI.

Parameters
prefixThe prefix of the attribute (if any). String.Empty and null are equivalent.
localNameThe local name of the attribute.
namespaceURIThe namespace URI of the attribute (if any). String.Empty and null are equivalent. If prefix is xmlns, then this parameter must be http://www.w3.org/2000/xmlns/; otherwise an exception is thrown.
Returns
The new XmlAttribute.

Reimplemented in System.Configuration.ConfigXmlDocument.

Definition at line 1256 of file XmlDocument.cs.

◆ CreateCDataSection()

virtual XmlCDataSection System.Xml.XmlDocument.CreateCDataSection ( string  data)
virtual

Creates an T:System.Xml.XmlCDataSection containing the specified data.

Parameters
dataThe content of the new XmlCDataSection.
Returns
The new XmlCDataSection.

Reimplemented in System.Configuration.ConfigXmlDocument.

Definition at line 811 of file XmlDocument.cs.

◆ CreateComment()

virtual XmlComment System.Xml.XmlDocument.CreateComment ( string  data)
virtual

Creates an T:System.Xml.XmlComment containing the specified data.

Parameters
dataThe content of the new XmlComment.
Returns
The new XmlComment.

Reimplemented in System.Configuration.ConfigXmlDocument.

Definition at line 820 of file XmlDocument.cs.

◆ CreateDefaultAttribute()

virtual internal XmlAttribute System.Xml.XmlDocument.CreateDefaultAttribute ( string  prefix,
string  localName,
string  namespaceURI 
)
protectedvirtual

Creates a default attribute with the specified prefix, local name and namespace URI.

Parameters
prefixThe prefix of the attribute (if any).
localNameThe local name of the attribute.
namespaceURIThe namespace URI of the attribute (if any).
Returns
The new T:System.Xml.XmlAttribute.

Definition at line 1266 of file XmlDocument.cs.

◆ CreateDocumentFragment()

virtual XmlDocumentFragment System.Xml.XmlDocument.CreateDocumentFragment ( )
virtual

Creates an T:System.Xml.XmlDocumentFragment.

Returns
The new XmlDocumentFragment.

Definition at line 839 of file XmlDocument.cs.

◆ CreateDocumentType()

virtual XmlDocumentType System.Xml.XmlDocument.CreateDocumentType ( string  name,
string  publicId,
string  systemId,
string  internalSubset 
)
virtual

Returns a new T:System.Xml.XmlDocumentType object.

Parameters
nameName of the document type.
publicIdThe public identifier of the document type or null. You can specify a public URI and also a system identifier to identify the location of the external DTD subset.
systemIdThe system identifier of the document type or null. Specifies the URL of the file location for the external DTD subset.
internalSubsetThe DTD internal subset of the document type or null.
Returns
The new XmlDocumentType.

Definition at line 832 of file XmlDocument.cs.

◆ CreateElement() [1/3]

XmlElement System.Xml.XmlDocument.CreateElement ( string  name)

Creates an element with the specified name.

Parameters
nameThe qualified name of the element. If the name contains a colon then the P:System.Xml.XmlNode.Prefix property reflects the part of the name preceding the colon and the P:System.Xml.XmlDocument.LocalName property reflects the part of the name after the colon. The qualified name cannot include a prefix of'xmlns'.
Returns
The new XmlElement.

Definition at line 847 of file XmlDocument.cs.

◆ CreateElement() [2/3]

XmlElement System.Xml.XmlDocument.CreateElement ( string  qualifiedName,
string  namespaceURI 
)

Creates an T:System.Xml.XmlElement with the qualified name and P:System.Xml.XmlNode.NamespaceURI.

Parameters
qualifiedNameThe qualified name of the element. If the name contains a colon then the P:System.Xml.XmlNode.Prefix property will reflect the part of the name preceding the colon and the P:System.Xml.XmlDocument.LocalName property will reflect the part of the name after the colon. The qualified name cannot include a prefix of'xmlns'.
namespaceURIThe namespace URI of the element.
Returns
The new XmlElement.

Definition at line 1110 of file XmlDocument.cs.

◆ CreateElement() [3/3]

virtual XmlElement System.Xml.XmlDocument.CreateElement ( string  prefix,
string  localName,
string  namespaceURI 
)
virtual

Creates an element with the specified P:System.Xml.XmlNode.Prefix, P:System.Xml.XmlDocument.LocalName, and P:System.Xml.XmlNode.NamespaceURI.

Parameters
prefixThe prefix of the new element (if any). String.Empty and null are equivalent.
localNameThe local name of the new element.
namespaceURIThe namespace URI of the new element (if any). String.Empty and null are equivalent.
Returns
The new T:System.Xml.XmlElement.

Reimplemented in System.Configuration.ConfigXmlDocument.

Definition at line 1276 of file XmlDocument.cs.

◆ CreateEntityReference()

virtual XmlEntityReference System.Xml.XmlDocument.CreateEntityReference ( string  name)
virtual

Creates an T:System.Xml.XmlEntityReference with the specified name.

Parameters
nameThe name of the entity reference.
Returns
The new XmlEntityReference.
Exceptions
T:System.ArgumentExceptionThe name is invalid (for example, names starting with'#' are invalid.)

Definition at line 914 of file XmlDocument.cs.

◆ CreateNavigator() [1/2]

override XPathNavigator System.Xml.XmlDocument.CreateNavigator ( )
virtual

Creates a new T:System.Xml.XPath.XPathNavigator object for navigating this document.

Returns
An T:System.Xml.XPath.XPathNavigator object.

Reimplemented from System.Xml.XmlNode.

Definition at line 957 of file XmlDocument.cs.

◆ CreateNavigator() [2/2]

virtual internal XPathNavigator System.Xml.XmlDocument.CreateNavigator ( XmlNode  node)
protectedvirtual

Creates an T:System.Xml.XPath.XPathNavigator object for navigating this document positioned on the T:System.Xml.XmlNode specified.

Parameters
nodeThe T:System.Xml.XmlNode you want the navigator initially positioned on.
Returns
An T:System.Xml.XPath.XPathNavigator object.

Definition at line 965 of file XmlDocument.cs.

◆ CreateNode() [1/3]

virtual XmlNode System.Xml.XmlDocument.CreateNode ( XmlNodeType  type,
string  prefix,
string  name,
string  namespaceURI 
)
virtual

Creates a T:System.Xml.XmlNode with the specified T:System.Xml.XmlNodeType, P:System.Xml.XmlNode.Prefix, P:System.Xml.XmlDocument.Name, and P:System.Xml.XmlNode.NamespaceURI.

Parameters
typeThe XmlNodeType of the new node.
prefixThe prefix of the new node.
nameThe local name of the new node.
namespaceURIThe namespace URI of the new node.
Returns
The new XmlNode.
Exceptions
T:System.ArgumentExceptionThe name was not provided and the XmlNodeType requires a name.

Definition at line 1293 of file XmlDocument.cs.

◆ CreateNode() [2/3]

virtual XmlNode System.Xml.XmlDocument.CreateNode ( string  nodeTypeString,
string  name,
string  namespaceURI 
)
virtual

Creates an T:System.Xml.XmlNode with the specified node type, P:System.Xml.XmlDocument.Name, and P:System.Xml.XmlNode.NamespaceURI.

Parameters
nodeTypeStringString version of the T:System.Xml.XmlNodeType of the new node. This parameter must be one of the values listed in the table below.
nameThe qualified name of the new node. If the name contains a colon, it is parsed into P:System.Xml.XmlNode.Prefix and P:System.Xml.XmlDocument.LocalName components.
namespaceURIThe namespace URI of the new node.
Returns
The new XmlNode.
Exceptions
T:System.ArgumentExceptionThe name was not provided and the XmlNodeType requires a name; or nodeTypeString is not one of the strings listed below.

Definition at line 1342 of file XmlDocument.cs.

◆ CreateNode() [3/3]

virtual XmlNode System.Xml.XmlDocument.CreateNode ( XmlNodeType  type,
string  name,
string  namespaceURI 
)
virtual

Creates an T:System.Xml.XmlNode with the specified T:System.Xml.XmlNodeType, P:System.Xml.XmlDocument.Name, and P:System.Xml.XmlNode.NamespaceURI.

Parameters
typeThe XmlNodeType of the new node.
nameThe qualified name of the new node. If the name contains a colon then it is parsed into P:System.Xml.XmlNode.Prefix and P:System.Xml.XmlDocument.LocalName components.
namespaceURIThe namespace URI of the new node.
Returns
The new XmlNode.
Exceptions
T:System.ArgumentExceptionThe name was not provided and the XmlNodeType requires a name.

Definition at line 1353 of file XmlDocument.cs.

◆ CreateProcessingInstruction()

virtual XmlProcessingInstruction System.Xml.XmlDocument.CreateProcessingInstruction ( string  target,
string  data 
)
virtual

Creates an T:System.Xml.XmlProcessingInstruction with the specified name and data.

Parameters
targetThe name of the processing instruction.
dataThe data for the processing instruction.
Returns
The new XmlProcessingInstruction.

Definition at line 923 of file XmlDocument.cs.

◆ CreateSignificantWhitespace()

virtual XmlSignificantWhitespace System.Xml.XmlDocument.CreateSignificantWhitespace ( string  text)
virtual

Creates an T:System.Xml.XmlSignificantWhitespace node.

Parameters
textThe string must contain only the following characters  
 
 and 	
Returns
A new XmlSignificantWhitespace node.

Reimplemented in System.Configuration.ConfigXmlDocument.

Definition at line 950 of file XmlDocument.cs.

◆ CreateTextNode()

virtual XmlText System.Xml.XmlDocument.CreateTextNode ( string  text)
virtual

Creates an T:System.Xml.XmlText with the specified text.

Parameters
textThe text for the Text node.
Returns
The new XmlText node.

Reimplemented in System.Configuration.ConfigXmlDocument.

Definition at line 942 of file XmlDocument.cs.

◆ CreateWhitespace()

virtual XmlWhitespace System.Xml.XmlDocument.CreateWhitespace ( string  text)
virtual

Creates an T:System.Xml.XmlWhitespace node.

Parameters
textThe string must contain only the following characters  
 
 and 	
Returns
A new XmlWhitespace node.

Reimplemented in System.Configuration.ConfigXmlDocument.

Definition at line 1081 of file XmlDocument.cs.

◆ CreateXmlDeclaration()

virtual XmlDeclaration System.Xml.XmlDocument.CreateXmlDeclaration ( string  version,
string  encoding,
string  standalone 
)
virtual

Creates an T:System.Xml.XmlDeclaration node with the specified values.

Parameters
versionThe version must be "1.0".
encodingThe value of the encoding attribute. This is the encoding that is used when you save the T:System.Xml.XmlDocument to a file or a stream; therefore, it must be set to a string supported by the T:System.Text.Encoding class, otherwise M:System.Xml.XmlDocument.Save(System.String) fails. If this is null or String.Empty, the Save method does not write an encoding attribute on the XML declaration and therefore the default encoding, UTF-8, is used.Note: If the XmlDocument is saved to either a T:System.IO.TextWriter or an T:System.Xml.XmlTextWriter, this encoding value is discarded. Instead, the encoding of the TextWriter or the XmlTextWriter is used. This ensures that the XML written out can be read back using the correct encoding.
standaloneThe value must be either "yes" or "no". If this is null or String.Empty, the Save method does not write a standalone attribute on the XML declaration.
Returns
The new XmlDeclaration node.
Exceptions
T:System.ArgumentExceptionThe values of version or standalone are something other than the ones specified above.

Definition at line 934 of file XmlDocument.cs.

◆ GetElementById()

virtual XmlElement System.Xml.XmlDocument.GetElementById ( string  elementId)
virtual

Gets the T:System.Xml.XmlElement with the specified ID.

Parameters
elementIdThe attribute ID to match.
Returns
The XmlElement with the matching ID or null if no matching element is found.

Definition at line 1130 of file XmlDocument.cs.

◆ GetElementsByTagName() [1/2]

virtual XmlNodeList System.Xml.XmlDocument.GetElementsByTagName ( string  name)
virtual

Returns an T:System.Xml.XmlNodeList containing a list of all descendant elements that match the specified P:System.Xml.XmlDocument.Name.

Parameters
nameThe qualified name to match. It is matched against the Name property of the matching node. The special value "*" matches all tags.
Returns
An T:System.Xml.XmlNodeList containing a list of all matching nodes. If no nodes match name , the returned collection will be empty.

Definition at line 1089 of file XmlDocument.cs.

◆ GetElementsByTagName() [2/2]

virtual XmlNodeList System.Xml.XmlDocument.GetElementsByTagName ( string  localName,
string  namespaceURI 
)
virtual

Returns an T:System.Xml.XmlNodeList containing a list of all descendant elements that match the specified P:System.Xml.XmlDocument.LocalName and P:System.Xml.XmlNode.NamespaceURI.

Parameters
localNameThe LocalName to match. The special value "*" matches all tags.
namespaceURINamespaceURI to match.
Returns
An T:System.Xml.XmlNodeList containing a list of all matching nodes. If no nodes match the specified localName and namespaceURI , the returned collection will be empty.

Definition at line 1122 of file XmlDocument.cs.

◆ ImportNode()

virtual XmlNode System.Xml.XmlDocument.ImportNode ( XmlNode  node,
bool  deep 
)
virtual

Imports a node from another document to the current document.

Parameters
nodeThe node being imported.
deeptrue to perform a deep clone; otherwise, false.
Returns
The imported T:System.Xml.XmlNode.
Exceptions
T:System.InvalidOperationExceptionCalling this method on a node type which cannot be imported.

Definition at line 1156 of file XmlDocument.cs.

◆ Load() [1/4]

virtual void System.Xml.XmlDocument.Load ( string  filename)
virtual

Loads the XML document from the specified URL.

Parameters
filenameURL for the file containing the XML document to load. The URL can be either a local file or an HTTP URL (a Web address).
Exceptions
T:System.Xml.XmlExceptionThere is a load or parse error in the XML. In this case, a T:System.IO.FileNotFoundException is raised.
T:System.ArgumentExceptionfilename is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars.
T:System.ArgumentNullExceptionfilename is null.
T:System.IO.PathTooLongExceptionThe specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
T:System.IO.DirectoryNotFoundExceptionThe specified path is invalid (for example, it is on an unmapped drive).
T:System.IO.IOExceptionAn I/O error occurred while opening the file.
T:System.UnauthorizedAccessExceptionfilename specified a file that is read-only.-or- This operation is not supported on the current platform.-or- filename specified a directory.-or- The caller does not have the required permission.
T:System.IO.FileNotFoundExceptionThe file specified in filename was not found.
T:System.NotSupportedExceptionfilename is in an invalid format.
T:System.Security.SecurityExceptionThe caller does not have the required permission.

Reimplemented in System.Configuration.ConfigXmlDocument.

Definition at line 1467 of file XmlDocument.cs.

◆ Load() [2/4]

virtual void System.Xml.XmlDocument.Load ( Stream  inStream)
virtual

Loads the XML document from the specified stream.

Parameters
inStreamThe stream containing the XML document to load.
Exceptions
T:System.Xml.XmlExceptionThere is a load or parse error in the XML. In this case, a T:System.IO.FileNotFoundException is raised.

Definition at line 1483 of file XmlDocument.cs.

◆ Load() [3/4]

virtual void System.Xml.XmlDocument.Load ( TextReader  txtReader)
virtual

Loads the XML document from the specified T:System.IO.TextReader.

Parameters
txtReaderThe TextReader used to feed the XML data into the document.
Exceptions
T:System.Xml.XmlExceptionThere is a load or parse error in the XML. In this case, the document remains empty.

Definition at line 1499 of file XmlDocument.cs.

◆ Load() [4/4]

virtual void System.Xml.XmlDocument.Load ( XmlReader  reader)
virtual

Loads the XML document from the specified T:System.Xml.XmlReader.

Parameters
readerThe XmlReader used to feed the XML data into the document.
Exceptions
T:System.Xml.XmlExceptionThere is a load or parse error in the XML. In this case, the document remains empty.

Definition at line 1515 of file XmlDocument.cs.

◆ LoadXml()

virtual void System.Xml.XmlDocument.LoadXml ( string  xml)
virtual

Loads the XML document from the specified string.

Parameters
xmlString containing the XML document to load.
Exceptions
T:System.Xml.XmlExceptionThere is a load or parse error in the XML. In this case, the document remains empty.

Definition at line 1539 of file XmlDocument.cs.

◆ ReadNode()

virtual XmlNode System.Xml.XmlDocument.ReadNode ( XmlReader  reader)
virtual

Creates an T:System.Xml.XmlNode object based on the information in the T:System.Xml.XmlReader. The reader must be positioned on a node or attribute.

Parameters
readerThe XML source
Returns
The new XmlNode or null if no more nodes exist.
Exceptions
T:System.NullReferenceExceptionThe reader is positioned on a node type that does not translate to a valid DOM node (for example, EndElement or EndEntity).

Definition at line 1363 of file XmlDocument.cs.

◆ Save() [1/4]

virtual void System.Xml.XmlDocument.Save ( string  filename)
virtual

Saves the XML document to the specified file. If the specified file exists, this method overwrites it.

Parameters
filenameThe location of the file where you want to save the document.
Exceptions
T:System.Xml.XmlExceptionThe operation would not result in a well formed XML document (for example, no document element or duplicate XML declarations).

Definition at line 1555 of file XmlDocument.cs.

◆ Save() [2/4]

virtual void System.Xml.XmlDocument.Save ( Stream  outStream)
virtual

Saves the XML document to the specified stream.

Parameters
outStreamThe stream to which you want to save.
Exceptions
T:System.Xml.XmlExceptionThe operation would not result in a well formed XML document (for example, no document element or duplicate XML declarations).

Definition at line 1580 of file XmlDocument.cs.

◆ Save() [3/4]

virtual void System.Xml.XmlDocument.Save ( TextWriter  writer)
virtual

Saves the XML document to the specified T:System.IO.TextWriter.

Parameters
writerThe TextWriter to which you want to save.
Exceptions
T:System.Xml.XmlExceptionThe operation would not result in a well formed XML document (for example, no document element or duplicate XML declarations).

Definition at line 1594 of file XmlDocument.cs.

◆ Save() [4/4]

virtual void System.Xml.XmlDocument.Save ( XmlWriter  w)
virtual

Saves the XML document to the specified T:System.Xml.XmlWriter.

Parameters
wThe XmlWriter to which you want to save.
Exceptions
T:System.Xml.XmlExceptionThe operation would not result in a well formed XML document (for example, no document element or duplicate XML declarations).

Definition at line 1607 of file XmlDocument.cs.

◆ Validate() [1/2]

void System.Xml.XmlDocument.Validate ( ValidationEventHandler  validationEventHandler)

Validates the T:System.Xml.XmlDocument against the XML Schema Definition Language (XSD) schemas contained in the P:System.Xml.XmlDocument.Schemas property.

Parameters
validationEventHandlerThe T:System.Xml.Schema.ValidationEventHandler object that receives information about schema validation warnings and errors.
Exceptions
T:System.Xml.Schema.XmlSchemaValidationExceptionA schema validation event occurred and no T:System.Xml.Schema.ValidationEventHandler object was specified.

Definition at line 1678 of file XmlDocument.cs.

◆ Validate() [2/2]

void System.Xml.XmlDocument.Validate ( ValidationEventHandler  validationEventHandler,
XmlNode  nodeToValidate 
)

Validates the T:System.Xml.XmlNode object specified against the XML Schema Definition Language (XSD) schemas in the P:System.Xml.XmlDocument.Schemas property.

Parameters
validationEventHandlerThe T:System.Xml.Schema.ValidationEventHandler object that receives information about schema validation warnings and errors.
nodeToValidateThe T:System.Xml.XmlNode object created from an T:System.Xml.XmlDocument to validate.
Exceptions
T:System.ArgumentExceptionThe T:System.Xml.XmlNode object parameter was not created from an T:System.Xml.XmlDocument.
T:System.InvalidOperationExceptionThe T:System.Xml.XmlNode object parameter is not an element, attribute, document fragment, or the root node.
T:System.Xml.Schema.XmlSchemaValidationExceptionA schema validation event occurred and no T:System.Xml.Schema.ValidationEventHandler object was specified.

Definition at line 1689 of file XmlDocument.cs.

◆ WriteContentTo()

override void System.Xml.XmlDocument.WriteContentTo ( XmlWriter  xw)
virtual

Saves all the children of the XmlDocument node to the specified T:System.Xml.XmlWriter.

Parameters
xwThe XmlWriter to which you want to save.

Implements System.Xml.XmlNode.

Definition at line 1654 of file XmlDocument.cs.

◆ WriteTo()

override void System.Xml.XmlDocument.WriteTo ( XmlWriter  w)
virtual

Saves the XmlDocument node to the specified T:System.Xml.XmlWriter.

Parameters
wThe XmlWriter to which you want to save.

Implements System.Xml.XmlNode.

Definition at line 1647 of file XmlDocument.cs.

Member Data Documentation

◆ BaseURI

override string System.Xml.XmlDocument.BaseURI => baseURI

Gets the base URI of the current node.

Returns
The location from which the node was loaded.

Definition at line 367 of file XmlDocument.cs.

◆ DocumentElement

XmlElement System.Xml.XmlDocument.DocumentElement => (XmlElement)FindChild(XmlNodeType.Element)

Gets the root T:System.Xml.XmlElement for the document.

Returns
The XmlElement that represents the root of the XML document tree. If no root exists, null is returned.

Definition at line 155 of file XmlDocument.cs.

◆ DocumentType

virtual XmlDocumentType System.Xml.XmlDocument.DocumentType => (XmlDocumentType)FindChild(XmlNodeType.DocumentType)

Gets the node containing the DOCTYPE declaration.

Returns
The T:System.Xml.XmlNode containing the DocumentType (DOCTYPE declaration).

Definition at line 127 of file XmlDocument.cs.

◆ Implementation

XmlImplementation System.Xml.XmlDocument.Implementation => implementation

Gets the T:System.Xml.XmlImplementation object for the current document.

Returns
The XmlImplementation object for the current document.

Definition at line 143 of file XmlDocument.cs.

◆ IsReadOnly

override bool System.Xml.XmlDocument.IsReadOnly => false

Gets a value indicating whether the current node is read-only.

Returns
true if the current node is read-only; otherwise false. XmlDocument nodes always return false.

Definition at line 250 of file XmlDocument.cs.

◆ LocalName

override string System.Xml.XmlDocument.LocalName => strDocumentName

Gets the local name of the node.

Returns
For XmlDocument nodes, the local name is #document.

Definition at line 151 of file XmlDocument.cs.

◆ Name

override string System.Xml.XmlDocument.Name => strDocumentName

Gets the qualified name of the node.

Returns
For XmlDocument nodes, the name is #document.

Definition at line 147 of file XmlDocument.cs.

◆ NameTable

XmlNameTable System.Xml.XmlDocument.NameTable => implementation.NameTable

Gets the T:System.Xml.XmlNameTable associated with this implementation.

Returns
An XmlNameTable enabling you to get the atomized version of a string within the document.

Definition at line 230 of file XmlDocument.cs.

◆ NodeType

override XmlNodeType System.Xml.XmlDocument.NodeType => XmlNodeType.Document

Gets the type of the current node.

Returns
The node type. For XmlDocument nodes, this value is XmlNodeType.Document.

Definition at line 119 of file XmlDocument.cs.

◆ OwnerDocument

override XmlDocument System.Xml.XmlDocument.OwnerDocument => null

Gets the T:System.Xml.XmlDocument to which the current node belongs.

Returns
For XmlDocument nodes (P:System.Xml.XmlDocument.NodeType equals XmlNodeType.Document), this property always returns null.

Definition at line 173 of file XmlDocument.cs.

◆ ParentNode

override XmlNode System.Xml.XmlDocument.ParentNode => null

Gets the parent node of this node (for nodes that can have parents).

Returns
Always returns null.

Definition at line 123 of file XmlDocument.cs.

Property Documentation

◆ InnerText

override string System.Xml.XmlDocument.InnerText
set

Throws an T:System.InvalidOperationException in all cases.

Returns
The values of the node and all its child nodes.
Exceptions
T:System.InvalidOperationExceptionIn all cases.

Definition at line 313 of file XmlDocument.cs.

◆ InnerXml

override string System.Xml.XmlDocument.InnerXml
getset

Gets or sets the markup representing the children of the current node.

Returns
The markup of the children of the current node.
Exceptions
T:System.Xml.XmlExceptionThe XML specified when setting this property is not well-formed.

Definition at line 324 of file XmlDocument.cs.

◆ NodeChanged

XmlNodeChangedEventHandler System.Xml.XmlDocument.NodeChanged
addremove

Occurs when the P:System.Xml.XmlNode.Value of a node belonging to this document has been changed.

Definition at line 453 of file XmlDocument.cs.

◆ NodeChanging

XmlNodeChangedEventHandler System.Xml.XmlDocument.NodeChanging
addremove

Occurs when the P:System.Xml.XmlNode.Value of a node belonging to this document is about to be changed.

Definition at line 440 of file XmlDocument.cs.

◆ NodeInserted

XmlNodeChangedEventHandler System.Xml.XmlDocument.NodeInserted
addremove

Occurs when a node belonging to this document has been inserted into another node.

Definition at line 401 of file XmlDocument.cs.

◆ NodeInserting

XmlNodeChangedEventHandler System.Xml.XmlDocument.NodeInserting
addremove

Occurs when a node belonging to this document is about to be inserted into another node.

Definition at line 388 of file XmlDocument.cs.

◆ NodeRemoved

XmlNodeChangedEventHandler System.Xml.XmlDocument.NodeRemoved
addremove

Occurs when a node belonging to this document has been removed from its parent.

Definition at line 427 of file XmlDocument.cs.

◆ NodeRemoving

XmlNodeChangedEventHandler System.Xml.XmlDocument.NodeRemoving
addremove

Occurs when a node belonging to this document is about to be removed from the document.

Definition at line 414 of file XmlDocument.cs.

◆ PreserveWhitespace

bool System.Xml.XmlDocument.PreserveWhitespace
getset

Gets or sets a value indicating whether to preserve white space in element content.

Returns
true to preserve white space; otherwise false. The default is false.

Definition at line 236 of file XmlDocument.cs.

◆ SchemaInfo

override IXmlSchemaInfo System.Xml.XmlDocument.SchemaInfo
get

Returns the Post-Schema-Validation-Infoset (PSVI) of the node.

Returns
The T:System.Xml.Schema.IXmlSchemaInfo object representing the PSVI of the node.

Definition at line 344 of file XmlDocument.cs.

◆ Schemas

XmlSchemaSet System.Xml.XmlDocument.Schemas
getset

Gets or sets the T:System.Xml.Schema.XmlSchemaSet object associated with this T:System.Xml.XmlDocument.

Returns
An T:System.Xml.Schema.XmlSchemaSet object containing the XML Schema Definition Language (XSD) schemas associated with this T:System.Xml.XmlDocument; otherwise, an empty T:System.Xml.Schema.XmlSchemaSet object.

Definition at line 178 of file XmlDocument.cs.

◆ XmlResolver

virtual XmlResolver System.Xml.XmlDocument.XmlResolver
set

Sets the T:System.Xml.XmlResolver to use for resolving external resources.

Returns
The XmlResolver to use.In version 1.1 of the.NET Framework, the caller must be fully trusted in order to specify an XmlResolver.
Exceptions
T:System.Xml.XmlExceptionThis property is set to null and an external DTD or entity is encountered.

Definition at line 201 of file XmlDocument.cs.


The documentation for this class was generated from the following file: