XML DOM - Node object
- Previous Page DOM NamedNodeMap
- Next Page DOM NodeList
A node object represents a node in the document tree.
Node object
The Node object is the main data type of the entire DOM.
A node object represents a single node in the document tree.
Nodes can be element nodes, attribute nodes, text nodes, or any type of node introduced in the "Node Type" section.
Please note that while all objects can inherit properties and methods used to handle parent and child nodes, not all objects have parent or child nodes. For example, text nodes cannot have child nodes, so adding child nodes to such nodes will result in a DOM error.
IE: Internet Explorer: F: Firefox: O: Opera: W3C: World Wide Web Consortium (Internet Standards)
Attributes of Node Object
Attribute | Description | IE | F | O | W3C |
---|---|---|---|---|---|
baseURI | Return the absolute base URI of the node. | No | 1 | No | Yes |
childNodes | Return the node list from the node to its child node. | 5 | 1 | 9 | Yes |
firstChild | Return the first child node of the node. | 5 | 1 | 9 | Yes |
lastChild | Return the last child node of the node. | 5 | 1 | 9 | Yes |
localName | Return the local name of the node. | No | 1 | 9 | Yes |
namespaceURI | Return the namespace URI of the node. | No | 1 | 9 | Yes |
nextSibling | Return the same-level node immediately following the node. | 5 | 1 | 9 | Yes |
nodeName | Return the name of the node, depending on its type. | 5 | 1 | 9 | Yes |
nodeType | Return the type of the node. | 5 | 1 | 9 | Yes |
nodeValue | Set or return the value of the node, depending on its type. | 5 | 1 | 9 | Yes |
ownerDocument | Return the root element of the node (document object). | 5 | 1 | 9 | Yes |
parentNode | Return the parent node of the node. | 5 | 1 | 9 | Yes |
prefix | Set or return the namespace prefix of the node. | No | 1 | 9 | Yes |
previousSibling | Return the same-level node immediately preceding the node. | 5 | 1 | 9 | Yes |
textContent | Set or return the text content of the node and its descendants. | No | 1 | No | Yes |
text | Return the text of the node and its descendants (IE-specific attribute). | 5 | No | No | No |
xml | Return the XML of the node and its descendants (IE-specific attribute). | 5 | No | No | No |
Methods of Node Object
Method | Description | IE | F | O | W3C |
---|---|---|---|---|---|
appendChild() | Add a new child node to the end of the node's child node list. | 5 | 1 | 9 | Yes |
cloneNode() | Copy a node. | 5 | 1 | 9 | Yes |
compareDocumentPosition() | Compare the document positions of two nodes. | No | 1 | No | Yes |
getFeature(feature,version) | Return a DOM object that can execute a specialized API with the specified features and versions. | No | Yes | ||
getUserData(key) | Return the object associated with a key on this node. This object must first be set to this node by calling setUserData with the same key. | No | Yes | ||
hasAttributes() | Determine whether the current node has attributes. | No | 1 | 9 | Yes |
hasChildNodes() | Determine whether the current node has child nodes. | 5 | 1 | 9 | Yes |
insertBefore() | Insert a new child node before the specified child node. | 5 | 1 | 9 | Yes |
isDefaultNamespace(URI) | Does the specified namespace URI return as the default. | No | Yes | ||
isEqualNode() | Check if two nodes are equal. | No | No | No | Yes |
isSameNode() | Check if two nodes are the same node. | No | 1 | No | Yes |
isSupported() | Return whether the current node supports a certain feature. | 9 | Yes | ||
lookupNamespaceURI() | Return the namespace URI that matches the specified prefix. | No | 1 | No | Yes |
lookupPrefix() | Return the prefix that matches the specified namespace URI. | No | 1 | No | Yes |
normalize() | Merge adjacent Text nodes and delete empty Text nodes. | 5 | 1 | 9 | Yes |
removeChild() | Delete (and return) the specified child node of the current node. | 5 | 1 | 9 | Yes |
replaceChild() | Replace a child node with a new node. | 5 | 1 | 9 | Yes |
selectNodes() | Query selected nodes using an XPath expression. | 6 | |||
selectSingleNode() | Find a node that matches an XPath query. | 6 | |||
transformNode() | Use XSLT to transform a node into a string. | 6 | |||
transformNodeToObject() | Use XSLT to transform a node into a document. | 6 | |||
setUserData(key, data, handler) | Associate an object with a key on a node. | No | Yes |
- Previous Page DOM NamedNodeMap
- Next Page DOM NodeList