Document Class

Use the Document class to process XML content. You can parse nested XML content that’s up to 50 nodes deep.

Namespace

Dom

Usage

One common application is to use it to create the body of a request for HttpRequest or to parse a response accessed by HttpResponse.

See Also

Document Constructors

The following are constructors for Document.

  • Document()
    Creates a new instance of the Dom.Document class.

Document()

Creates a new instance of the Dom.Document class.

Signature

public Document()

Document Methods

The following are methods for Document. All are instance methods.

  • createRootElement(name, namespace, prefix)
    Creates the top-level root element for a document.
  • getRootElement()
    Returns the top-level root element node in the document. If this method returns null, the root element has not been created yet.
  • load(xml)
    Parse the XML representation of the document specified in the xml argument and load it into a document.
  • toXmlString()
    Returns the XML representation of the document as a String.

createRootElement(name, namespace, prefix)

Creates the top-level root element for a document.

Signature

public Dom.XmlNode createRootElement(String name, String namespace, String prefix)

Parameters

name
Type: String
namespace
Type: String
prefix
Type: String

Return Value

Type: Dom.XmlNode

Usage

For more information about namespaces, see XML Namespaces.

Calling this method more than once on a document generates an error as a document can have only one root element.

getRootElement()

Returns the top-level root element node in the document. If this method returns null, the root element has not been created yet.

Signature

public Dom.XmlNode getRootElement()

Return Value

Type: Dom.XmlNode

load(xml)

Parse the XML representation of the document specified in the xml argument and load it into a document.

Signature

public Void load(String xml)

Parameters

xml
Type: String

Return Value

Type: Void

Example

Dom.Document doc = new Dom.Document();
doc.load(xml);

toXmlString()

Returns the XML representation of the document as a String.

Signature

public String toXmlString()

Return Value

Type: String