XML DOM Node Object
- Previous Page DOM Node Types
- Next Page DOM NodeList
Node object
The Node object represents a single node in the document tree.
A node can be an element node, attribute node, text node, or any type of node introduced in the 'Node Type' chapter.
Note that while all objects can inherit properties and methods used to handle parent nodes and child nodes, not all objects have parent nodes or child nodes. For example, text nodes cannot have child nodes, so adding child nodes to similar nodes will cause a DOM error.
Attributes of Node object
Attributes | Description |
---|---|
attributes | Contains the NamedNodeMap of attributes for this node (if the node is an element). |
baseURI | Returns the absolute base URI of the node. |
childNodes | Returns the NodeList of the node's child nodes. |
firstChild | Returns the first child node of the node. |
lastChild | Returns the last child node of the node. |
nextSibling | Returns the immediate sibling node following the node. |
nodeName | Returns the name of the node, depending on its type. |
nodeType | Returns the type of the node. |
nodeValue | Sets or returns the value of the node, depending on its type. |
ownerDocument | Returns the root element (document object) of the node. |
parentNode | Returns the parent node of the node. |
prefix | Sets or returns the namespace prefix of the node. |
previousSibling | Returns the immediate sibling node preceding the node. |
textContent | Sets or returns the text content of the node and its descendants. |
Methods of Node object
Method | Description |
---|---|
appendChild() | Appends a new child node to the end of the node's child node list. |
cloneNode() | Clones a node. |
compareDocumentPosition() | Compares the position of two nodes in the DOM hierarchy (document). |
getFeature(feature,version) | Returns a DOM object that implements the specialized API for the specified features and versions. |
getUserData(key) |
Returns the object associated with the key on the node. The object must first be set to this node, using the same key to call setUserData. |
hasAttributes() | Return true if the specified node has any attributes, otherwise return false. |
hasChildNodes() | Return true if the specified node has child nodes, otherwise return false. |
insertBefore() | Insert a new child node before the specified child node. |
isDefaultNamespace(URI) | Return whether the specified namespace URI is the default. |
isEqualNode() | Check if two nodes are equal. |
isSameNode() | Check if two nodes are the same node. |
lookupNamespaceURI() | Return the namespace URI associated with the given prefix. |
lookupPrefix() | Return the prefix associated with the given namespace URI. |
normalize() | Merge adjacent text nodes and delete empty text nodes. |
removeChild() | Remove (and return) the specified child node of the current node. |
replaceChild() | Replace the child node with a new node. |
setUserData(key,data,handler) | Associate an object with a key on the node. |
- Previous Page DOM Node Types
- Next Page DOM NodeList