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.
Integer ELEMENT_NODE
The node is an DOMElement.
ATTRIBUTE_NODEInteger ATTRIBUTE_NODE
The node is an DOMAttr.
TEXT_NODEInteger TEXT_NODE
The node is an DOMText.
CDATA_SECTION_NODEInteger CDATA_SECTION_NODE
The node is an DOMCDATASection.
ENTITY_REFERENCE_NODEInteger ENTITY_REFERENCE_NODE
The node is an DOMEntityReference.
ENTITY_NODEInteger ENTITY_NODE
The node is an DOMEntity.
PROCESSING_INSTRUCTION_NODEInteger PROCESSING_INSTRUCTION_NODE
The node is an DOMProcessingInstruction.
COMMENT_NODEInteger COMMENT_NODE
The node is an DOMComment.
DOCUMENT_NODEInteger DOCUMENT_NODE
The node is an DOMDocument.
DOCUMENT_TYPE_NODEInteger DOCUMENT_TYPE_NODE
The node is an DOMDocumentType.
DOCUMENT_FRAGMENT_NODEInteger DOCUMENT_FRAGMENT_NODE
The node is an DOMDocumentFragment.
NOTATION_NODEInteger NOTATION_NODE
The node is an DOMNotation.
GetNodeNameString GetNodeName()
The name of this node.
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.
Void SetNodeValue( String nodeValue )
Sets the value of the node.
nodeValue | - | The value to set the node |
Integer GetNodeType()
A code representing the type of the underlying object, as defined above.
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.
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.
DOMNode GetFirstChild()
The first child of this node. If there is no such node, this returns null.
DOMNode GetLastChild()
The last child of this node. If there is no such node, this returns null.
DOMNode GetPreviousSibling()
The node immediately preceding this node. If there is no such node, this returns null.
DOMNode GetNextSibling()
The node immediately following this node. If there is no such node, this returns null.
DOMNamedNodeMap GetAttributes()
A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
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.
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.
newChild | - | The node to insert. |
refChild | - | The reference node, i.e., the node before which the new node must be inserted. |
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.
newChild | - | The new node to put in the child list. |
oldChild | - | The node being replaced in the list. |
DOMNode RemoveChild( DOMNode oldChild )
Removes the child node indicated by oldChild from the list of children, and returns it.
oldChild | - | The node being removed. |
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.
newChild | - | The node to add. |
Boolean HasChildNodes()
This is a convenience method to allow easy determination of whether a node has any children.
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.
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). |
Dynamic Cast()
Cast the DOMNode to the appropriate type.