From http://www.w3schools.com (Copyright Refsnes Data)

XML DOM - The Node Object

prev next

The Node object represents a node in the document tree.


The Node Object

The Node object is the primary data type for the entire DOM.

The Node object represents a single node in the document tree.

A node can be an element node, an attribute node, a text node, or any other of the node types explained in the "Node types" chapter.

Notice that while all objects inherits the Node properties / methods for dealing with parents and children, not all objects can have parents or children. For example, Text nodes may not have children, and adding children to such nodes results in a DOM error.

IE: Internet Explorer, F: Firefox, O: Opera, W3C: World Wide Web Consortium (Internet Standard)

Node Object Properties

Property Description IE F O W3C
baseURI Returns the absolute base URI of a node No 1 No Yes
childNodes Returns a NodeList of child nodes for a node 5 1 9 Yes
firstChild Returns the first child of a node 5 1 9 Yes
lastChild Returns the last child of a node 5 1 9 Yes
localName Returns the local part of the name of a node No 1 9 Yes
namespaceURI Returns the namespace URI of a node No 1 9 Yes
nextSibling Returns the node immediately following a node 5 1 9 Yes
nodeName Returns the name of a node, depending on its type 5 1 9 Yes
nodeType Returns the type of a node 5 1 9 Yes
nodeValue Sets or returns the value of a node, depending on its type 5 1 9 Yes
ownerDocument Returns the root element (document object) for a node 5 1 9 Yes
parentNode Returns the parent node of a node 5 1 9 Yes
prefix Sets or returns the namespace prefix of a node No 1 9 Yes
previousSibling Returns the node immediately before a node 5 1 9 Yes
textContent Sets or returns the textual content of a node and its descendants No 1 No Yes
text Returns the text of a node and its descendants. IE-only property 5 No No No
xml Returns the XML of a node and its descendants. IE-only property 5 No No No

Node Object Methods

Method Description IE F O W3C
appendChild() Adds a new child node to the end of the list of children of a node 5 1 9 Yes
cloneNode() Clones a node 5 1 9 Yes
compareDocumentPosition() Compares the document position of two nodes No 1 No Yes
getFeature(feature,version) Returns a DOM object which implements the specialized APIs of the specified feature and version     No Yes
getUserData(key) Returns the object associated to a key on a this node. The object must first have been set to this node by calling setUserData with the same key     No Yes
hasAttributes() Returns true if a node has any attributes, otherwise it returns false No 1 9 Yes
hasChildNodes() Returns true if a node has any child nodes, otherwise it returns false 5 1 9 Yes
insertBefore() Inserts a new child node before an existing child node 5 1 9 Yes
isDefaultNamespace(URI) Returns whether the specified namespaceURI is the default     No Yes
isEqualNode() Checks if two nodes are equal No No No Yes
isSameNode() Checks if two nodes are the same node No 1 No Yes
isSupported(feature,version) Returns whether a specified feature is supported on a node     9 Yes
lookupNamespaceURI() Returns the namespace URI matching a specified prefix No 1 No Yes
lookupPrefix() Returns the prefix matching a specified namespace URI No 1 No Yes
normalize() Puts all text nodes underneath a node (including attributes) into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes 5 1 9 Yes
removeChild() Removes a child node 5 1 9 Yes
replaceChild() Replaces a child node 5 1 9 Yes
setUserData(key,data,handler) Associates an object to a key on a node     No Yes


prev next

From http://www.w3schools.com (Copyright Refsnes Data)