public interface Node
Known Indirect Subclasses

The Node 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.

The values of nodeName, nodeValue, and attributes vary according to the node type as follows:

Interface nodeName nodeValue attributes
Attr same as same as Attr.value null
CDATASection "#cdata-section" same as, the content of the CDATA Section null
Comment "#comment" same as, the content of the comment null
Document "#document" null null
DocumentFragment "#document-fragment" null null
DocumentType same as null null
Element same as Element.tagName null NamedNodeMap
Entity entity name null null
EntityReference name of entity referenced null null
Notation notation name null null
ProcessingInstruction same as same as null
Text "#text" same as, the content of the text node null

See also the Document Object Model (DOM) Level 3 Core Specification.

Constant Summary

short ATTRIBUTE_NODE The node is an Attr.
short CDATA_SECTION_NODE The node is a CDATASection.
short COMMENT_NODE The node is a Comment.
short DOCUMENT_FRAGMENT_NODE The node is a DocumentFragment.
short DOCUMENT_NODE The node is a Document.
short DOCUMENT_POSITION_CONTAINED_BY The node is contained by the reference node.
short DOCUMENT_POSITION_CONTAINS The node contains the reference node.
short DOCUMENT_POSITION_DISCONNECTED The two nodes are disconnected.
short DOCUMENT_POSITION_FOLLOWING The node follows the reference node.
short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC The determination of preceding versus following is implementation-specific.
short DOCUMENT_POSITION_PRECEDING The second node precedes the reference node.
short DOCUMENT_TYPE_NODE The node is a DocumentType.
short ELEMENT_NODE The node is an Element.
short ENTITY_NODE The node is an Entity.
short ENTITY_REFERENCE_NODE The node is an EntityReference.
short NOTATION_NODE The node is a Notation.
short PROCESSING_INSTRUCTION_NODE The node is a ProcessingInstruction.
short TEXT_NODE The node is a Text node.

Public Method Summary

abstract Node
appendChild(Node newChild)
Adds the node newChild to the end of the list of children of this node.
abstract Node
cloneNode(boolean deep)
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.
abstract short
compareDocumentPosition(Node other)
Compares the reference node, i.e.
abstract NamedNodeMap
A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
abstract String
The absolute base URI of this node or null if the implementation wasn't able to obtain an absolute URI.
abstract NodeList
A NodeList that contains all children of this node.
abstract Object
getFeature(String feature, String version)
This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in .
abstract Node
The first child of this node.
abstract Node
The last child of this node.
abstract String
Returns the local part of the qualified name of this node.
abstract String
The namespace URI of this node, or null if it is unspecified (see ).
abstract Node
The node immediately following this node.
abstract String
The name of this node, depending on its type; see the table above.
abstract short
A code representing the type of the underlying object, as defined above.
abstract String
The value of this node, depending on its type; see the table above.