OScript API/Built-in Package Index

Class: DOMNode

The DOMNode interface is the primary datatype for the entire Document Object Model. It represents a single node in the document tree. While all objects implementing the Node interface expose methods for dealing with children, not all objects implementing the Node interface may have children. For example, Text nodes may not have children, and adding children to such nodes results in a DOMException being raised. The attributes nodeName, nodeValue and attributes are included as a mechanism to get at node information without casting down to the specific derived interface. In cases where there is no obvious mapping of these attributes for a specific nodeType (e.g., nodeValue for an Element or attributes for a Comment), this returns null. Note that the specialized interfaces may contain additional and more convenient mechanisms to get and set the relevant information.

Class Attributes

The node is a DOMAttr.

The node is a DOMCDATASection.

The node is a DOMComment.

The node is a DOMDocumentFragment.

The node is a DOMDocument.

The node is a DOMDocumentType.

The node is an DOMElement.

The node is a DOMNode.

The node is a DOMEntityReference.

The node is a DOMNotation.

The node is a DOMProcessingInstruction.

The node is a DOMText.

Instance Methods

AppendChild( DOMNode newChild )

Append the newChild node.

Cast( )

Cast the node to the appropriate type.

CloneNode( Boolean deep )

Duplicate the node.

The attributes of this node.

A list of child nodes.

The first child of this node.

The last child of this node.

Returns the local part of the qualified name of this node.

Get the namespace URI of this node, or undefined if it is not specified.

The next sibling of this node.

The name of this node.

The type of node.

The value of this node.

The DOMDocument object that this node belongs to.

The parent of this node.

Get the namespace prefix of this node, or undefined.

The previous sibling of this node.

Determine if a node has attributes.

Determine if a node has children.

InsertBefore( DOMNode newChild, DOMNode refChild )

Insert the newChild node before the refChild node.

IsSupported( String feature, String version )

Returns true if the specified feature is supported on this node, false otherwise.

MustRelease( mustRelease )

Sets the mustRelease flag if optional parameter is specified, else returns the current value.

Puts all DOMText nodes in the full depth of the sub-tree underneath this DOMNode into a "normal" form where only markup separates DOMText nodes.

RemoveChild( DOMNode oldChild )

Remove the oldChild node.

ReplaceChild( DOMNode newChild, DOMNode oldChild )

Replace the oldChild node with the newChild node.

SetNodeValue( String nodeValue )

Sets the value of the this node.

SetPrefix( String prefix )

Set the namespace prefix of this node.

Class Attributes

The node is an DOMAttr.

The node is an DOMCDATASection.

Integer COMMENT_NODE

The node is an DOMComment.

The node is an DOMDocumentFragment.

Integer DOCUMENT_NODE

The node is an DOMDocument.

The node is an DOMDocumentType.

Integer ELEMENT_NODE

The node is an DOMElement.

Integer ENTITY_NODE

The node is an DOMEntity.

The node is an DOMEntityReference.

Integer NOTATION_NODE

The node is an DOMNotation.

The node is an DOMProcessingInstruction.

Integer TEXT_NODE

The node is an DOMText.

Instance Methods

AppendChild

DOMNode AppendChild( DOMNode newChild )

Adds the node newChild to the end of the list of children of this node. If the newChild is already in the tree, it is first removed.

Parameters

newChild

The node to add.

Returns:

The node added.

Cast

Dynamic Cast()

Cast the DOMNode to the appropriate type.

Returns:

The actual type of this node (e.g. DOMElement, DOMText, etc.).

CloneNode

DOMNode CloneNode( Boolean deep )

Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The duplicate node has no parent (parentNode returns null.). Cloning an Element copies all attributes and their values, including those generated by the XML processor to represent defaulted attributes, but this method does not copy any text it contains unless it is a deep clone, since the text is contained in a child Text node. Cloning any other type of node simply returns a copy of this node. Note that cloning an immutable subtree results in a mutable copy, but the children of an EntityReference clone are readonly.

Parameters

deep

If true, recursively clone the subtree under the specified node; if false, clone only the node itself (and its attributes, if it is an Element).

Returns:

The duplicate node.

GetAttributes

DOMNamedNodeMap GetAttributes()

A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.

Returns:

A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.

GetChildNodes

DOMNodeList GetChildNodes()

A NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes. The content of the returned NodeList is "live" in the sense that, for instance, changes to the children of the node object that it was created from are immediately reflected in the nodes returned by the NodeList accessors; it is not a static snapshot of the content of the node. This is true for every NodeList, including the ones returned by the getElementsByTagName method.

Returns:

A DOMNodeList of the children.

GetFirstChild

DOMNode GetFirstChild()

The first child of this node. If there is no such node, this returns null.

Returns:

A DOMNode representing the first child.

GetLastChild

DOMNode GetLastChild()

The last child of this node. If there is no such node, this returns null.

Returns:

A DOMNode representing the last child.

GetLocalName

String GetLocalName()

Returns the local part of the qualified name of this node.

Returns:

The local part of the qualified name.

GetNamespaceURI

String GetNamespaceURI()

Get the namespace URI of this node, or undefined if it is not specified.

Returns:

Namespace URI or undefined.

GetNextSibling

DOMNode GetNextSibling()

The node immediately following this node. If there is no such node, this returns null.

Returns:

The node immediately following this node.

GetNodeName

String GetNodeName()

The name of this node.

Returns:

The name of this node.

GetNodeType

Integer GetNodeType()

A code representing the type of the underlying object, as defined above.

Returns:

A code representing the type of the underlying object.

GetNodeValue

String GetNodeValue()

The value of this node, depending on its type; see the table above. When it is defined to be null, setting it has no effect.

Returns:

The value of this node.

GetOwnerDocument

DOMDocument GetOwnerDocument()

The Document object associated with this node. This is also the Document object used to create new nodes. When this node is a Document or a DocumentType which is not used with any Document yet, this is null.

Returns:

The Document object associated with this node.

GetParentNode

DOMNode GetParentNode()

The parent of this node. All nodes, except Attr, Document, DocumentFragment, Entity, and Notation may have a parent. However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is null.

Returns:

A DOMNode that represents the parent.

GetPrefix

String GetPrefix()

Get the namespace prefix of this node, or undefined.

Returns:

The namespace prefix or undefined.

GetPreviousSibling

DOMNode GetPreviousSibling()

The node immediately preceding this node. If there is no such node, this returns null.

Returns:

The node immediately preceding this node.

HasAttributes

Boolean HasAttributes()

Determine if a node has attributes.

Returns:

TRUE if this node has any attributes, FALSE otherwise.

HasChildNodes

Boolean HasChildNodes()

This is a convenience method to allow easy determination of whether a node has any children.

Returns:

True if the node has any children, false if the node has no children.

InsertBefore

DOMNode InsertBefore( DOMNode newChild,
                      DOMNode refChild )

Inserts the node newChild before the existing child node refChild. If refChild is null, insert newChild at the end of the list of children. If newChild is a DocumentFragment object, all of its children are inserted, in the same order, before refChild. If the newChild is already in the tree, it is first removed.

Parameters

newChild

The node to insert.

refChild

The reference node, i.e., the node before which the new node must be inserted.

Returns:

The node being inserted

IsSupported

Boolean IsSupported( String feature,
                     String version )

Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.

Parameters

feature

The feature name to tested.

version

This is the version number of the feature to test.

Returns:

TRUE if the specified feature is supported on this node, FALSE otherwise.

MustRelease

Boolean MustRelease( mustRelease )

Sets the mustRelease flag if the optional parameter is specified, else returns the current value. If mustRelease is set to TRUE then the DOMNode is released when the object goes out of scope.

Parameters

mustRelease

Value to set.

Returns:

The current value.

Normalize

Void Normalize()

Puts all DOMText nodes in the full depth of the sub-tree underneath this DOMNode, including attribute nodes, into a "normal" form where only markup (e.g., tags, comments, processing instructions, CDATA sections, and entity references) separates DOMText nodes, i.e., there are neither adjacent DOMText nodes nor empty DOMText nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer lookups) that depend on a particular document tree structure are to be used.

Returns:

RemoveChild

DOMNode RemoveChild( DOMNode oldChild )

Removes the child node indicated by oldChild from the list of children, and returns it.

Parameters

oldChild

The node being removed.

Returns:

The node removed.

ReplaceChild

DOMNode ReplaceChild( DOMNode newChild,
                      DOMNode oldChild )

Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node. If newChild is a DocumentFragment object, refChild is replaced by all of the DocumentFragment children, which are inserted in the same order. If the newChild is already in the tree, it is first removed.

Parameters

newChild

The new node to put in the child list.

oldChild

The node being replaced in the list.

Returns:

The node replaced.

SetNodeValue

Void SetNodeValue( String nodeValue )

Sets the value of the node.

Parameters

nodeValue

The value to set the node

Returns:

SetPrefix

Void SetPrefix( String prefix )

Set the namespace prefix of this node.

Parameters

prefix

The prefix value

Returns:

 Copyright © 2022 OpenText Corporation. All rights reserved.