2022 June Release

Interface XmlDocument Permanent link for this heading

This interface describes methods and properties available to work with XML documents.
Conceptually, it is the root of the document tree, and provides the primary access to the document's data. The XmlNode objects created have a ownerDocument attribute which associates them with the XmlDocument within whose context they were created.

See also the Document Object Model (DOM) Level 3 Core Specification.

Methods Permanent link for this heading

Return Type

Signature

XmlNode

CreateAttribute(
  string data)

XmlNode

CreateCDATASection(
  string data)

XmlNode

CreateComment(
  string data)

XmlNode

CreateElement(
  string tagname)

XmlNode

CreateElementNS(
  string namespaceURI,
  string qualifiedName)

XmlNode

CreateTextNode(
  string data)

string

GetXML(
  optional boolean preserve,
  optional boolean escape)

XmlNodeList

Query(
  string xpath)

Properties Permanent link for this heading

Type

Property

XmlNode

documentelement

Methods Permanent link for this heading


CreateAttribute Permanent link for this heading

Creates an Attr of the given name. Note that the XmlNode instance can then be set on an XmlNode using the AppendChild method.
To create an attribute with a qualified name and namespace URI, use the CreateAttributeNS method.

XmlNode CreateAttribute(
  string data)

Name

Description

data

The data for the node.

CreateCDATASection Permanent link for this heading

Creates a CDATA node given the specified string.

XmlNode CreateCDATASection(
  string data)

Name

Description

data

The data for the node.

CreateComment Permanent link for this heading

Creates a Comment node given the specified string.

XmlNode CreateComment(
  string data)

Name

Description

data

The data for the node.

CreateElement Permanent link for this heading

Creates an element with the nodename tagname. Note that the instance returned implements the XmlNode interface, so attributes can be specified directly on the returned object.
To create an element with a qualified name and namespace URI, use the CreateElementNS method.

XmlNode CreateElement(
  string tagname)

Name

Description

tagname

The name of the element type to instantiate. This is case-sensitive.

CreateElementNS Permanent link for this heading

Creates an element with a namespace. Note that the instance returned implements the XmlNode interface, so attributes can be specified directly on the returned object.

XmlNode CreateElementNS(
  string namespaceURI,
  string qualifiedName)

Name

Description

namespaceURI

The namespace URI of the element to create.

qualifiedName

The qualified name of the element to instantiate.

CreateTextNode Permanent link for this heading

Creates an XmlNode node given the specified string.

XmlNode CreateTextNode(
  string data)

Name

Description

data

The data for the node.

GetXML Permanent link for this heading

Returns the XML representation of the XmlDocument.
if preserve is true, the original XML is returned, otherwise the XML is normalized.

string GetXML(
  optional boolean preserve,
  optional boolean escape)

Name

Description

preserve

Keep whitespace structure.

escape

create a string that is XML escaped.

Query Permanent link for this heading

Returns an XmlNodeList of all the XmlNodes matching a given XPath and contained in the document.

XmlNodeList Query(
  string xpath)

Name

Description

xpath

The XPath which is evaluated to get the XmlNodes.

Properties Permanent link for this heading


documentelement Permanent link for this heading

The top XmlNode of the document.

XmlNode documentelement