OScript API/Built-in Package Index

Class: DOMDocument

The Document interface represents the entire HTML or XML document. Conceptually, it is the root of the document tree, and provides the primary access to the document's data.

Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a Document, the Document interface also contains the factory methods needed to create these objects. The Node objects created have a ownerDocument attribute which associates them with the Document within whose context they were created.

Class Methods

New( )

Create a new DOMDocument node.

Instance Methods

CreateAttribute( String name )

Creates an Attr of the given name.

CreateAttributeNS( String namespaceURI, String qualifiedName )

Creates an attribute of the given qualified name and namespace URI.

CreateCDATASection( String data )

Creates a CDATASection node whose value is the specified string.

CreateComment( String data )

Creates a Comment node given the specified string.

Creates an empty DocumentFragment object.

CreateElement( String tagName )

Creates an element of the type specified.

CreateElementNS( String namespaceURI, String qualifiedName )

Creates an element of the given qualified name and namespace URI.

CreateEntityReference( String name )

Creates an EntityReference object.

CreateProcessingInstruction( String target, String data )

Creates a ProcessingInstruction node given the specified name and data strings.

CreateTextNode( String data )

Creates a Text node given the specified string.

The Document Type Declaration (see DocumentType) associated with this document.

This is a convenience attribute that allows direct access to the child node that is the root element of the document.

GetElementById( String elementId )

Returns the DOMElement whose ID is given by elementId. If no such element exists, returns undefined.

GetElementsByTagName( String tagName )

Returns a NodeList of all the Elements with a given tag name in the order in which they would be encountered in a preorder traversal of the Document tree.

GetElementsByTagNameNS( String namespaceURI, String localName )

Returns a DOMNodeList of all the DOMElement(s) with a given local name and namespace URI.

The DOMImplementation object that handles this document.

ImportNode( DOMNode importedNode, Boolean deep )

Imports importedNode from another document to this document

Class Methods

New

DOMDocument New()

Create a new DOMDocument node, to be used to build a DOM tree in memory.

Returns:

The new DOMDocument node.

Instance Methods

CreateAttribute

DOMAttr CreateAttribute( String name )

Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttribute method.

Parameters

name

The name of the attribute.

Returns:

A new DOMAttr object.

CreateAttributeNS

DOMAttr CreateAttributeNS( String namespaceURI,
                           String qualifiedName )

Creates an attribute of the given qualified name and namespace URI.

Parameters

namespaceURI

The namespace URI of the attribute to create.

qualifiedName

The qualified name of the attribute to instantiate.

Returns:

A new DOMAttr object.

CreateCDATASection

DOMCDATASection CreateCDATASection( String data )

Creates a CDATASection node whose value is the specified string.

Parameters

data

The data for the CDATASection node.

Returns:

A new DOMCDATASection object.

CreateComment

DOMComment CreateComment( String data )

Creates a Comment node given the specified string.

Parameters

data

The data for the comment node.

Returns:

A new DOMComment object.

CreateDocumentFragment

DOMDocumentFragment CreateDocumentFragment()

Creates an empty DocumentFragment object.

Returns:

A new DOMDocumentFragment object.

CreateElement

DOMElement CreateElement( String tagName )

Creates an element of the type specified. Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object. In addition, if there are known attributes with default values, Attr nodes representing them are automatically created and attached to the element.

Parameters

tagName

The name of the element.

Returns:

A new DOMElement object with the nodeName attribute set to tagName.

CreateElementNS

DOMElement CreateElementNS( String namespaceURI,
                            String qualifiedName )

Creates an element of the given qualified name and namespace URI.

Parameters

namespaceURI

The namespace URI of the element to be created.

qualifiedName

The qualified name of the element type to instantiate.

Returns:

The newly created DOMElement object.

CreateEntityReference

DOMEntityReference CreateEntityReference( String name )

Creates an EntityReference object. In addition, if the referenced entity is known, the child list of the EntityReference node is made the same as that of the corresponding Entity node.

Parameters

name

The name of the entity to reference.

Returns:

A new DOMEntityReference object.

CreateProcessingInstruction

DOMProcessingInstruction CreateProcessingInstruction( String target,
                                                      String data )

Creates a ProcessingInstruction node given the specified name and data strings.

Parameters

target

The target part of the processing instruction.

data

The data for the node.

Returns:

A new DOMProcessingInstruction object.

CreateTextNode

DOMText CreateTextNode( String data )

Creates a Text node given the specified string.

Parameters

data

The data for the text node.

Returns:

A new DOMText object.

GetDoctype

DOMDocumentType GetDoctype()

The Document Type Declaration (see DocumentType) associated with this document. For HTML documents as well as XML documents without a document type declaration this returns null. The DOM Level 2 does not support editing the Document Type Declaration, therefore docType cannot be altered in any way, including through the use of methods, such as insertNode or removeNode, inherited from Node. Not implemented.

Returns:

The DOMDocumentType node representing the DTD.

GetDocumentElement

DOMElement GetDocumentElement()

This is a convenience attribute that allows direct access to the child node that is the root element of the document.

Returns:

The DOMElement that represents the root node.

GetElementById

DOMElement GetElementById( String elementId )

Returns the DOMElement whose ID is given by elementId. If no such element exists, returns undefined.

Parameters

elementId

The element ID string.

Returns:

The DOMElement specified by elementID.

GetElementsByTagName

DOMNodeList GetElementsByTagName( String tagName )

Returns a NodeList of all the Elements with a given tag name in the order in which they would be encountered in a preorder traversal of the Document tree.

Parameters

tagName

The name of the tag to match on. The special value "*" matches all tags.

Returns:

A new NodeList object containing all the matched Elements.

GetElementsByTagNameNS

DOMElement GetElementsByTagNameNS( String namespaceURI,
                                   String localName )

Returns a DOMNodeList of all the DOMElement(s) with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the DOMDocument tree.

Parameters

namespaceURI

The namespace URI of the elements to match on. The special value "*" matches all namespaces.

localName

The local name of the elements to match on. The special value "*" matches all local names.

Returns:

The DOMNodeList of all DOMNodes specified by the namespace URI and the local name.

GetImplementation

DOMImplementation GetImplementation()

The DOMImplementation object that handles this document. A DOM application may use objects from multiple implementations.

Returns:

The DOMImplementation object that handles this document.

ImportNode

DOMNode ImportNode( DOMNode importedNode,
                    Boolean deep )

Imports importedNode from another document to this document If deep is set to TRUE then all children nodes are also imported

Parameters

importedNode

The DOMNode to be imported

deep

If TRUE then import all sub nodes

Returns:

The imported node

 Copyright © 2022 OpenText Corporation. All rights reserved.