|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
, CDATASection
, CharacterData
, Comment
, Document
, DocumentFragment
, DocumentType
, Element
, Entity
, EntityReference
, HTMLAnchorElement
, HTMLAppletElement
, HTMLAreaElement
, HTMLBaseElement
, HTMLBaseFontElement
, HTMLBodyElement
, HTMLBRElement
, HTMLButtonElement
, HTMLDirectoryElement
, HTMLDivElement
, HTMLDListElement
, HTMLDocument
, HTMLElement
, HTMLFieldSetElement
, HTMLFontElement
, HTMLFormElement
, HTMLFrameElement
, HTMLFrameSetElement
, HTMLHeadElement
, HTMLHeadingElement
, HTMLHRElement
, HTMLHtmlElement
, HTMLIFrameElement
, HTMLImageElement
, HTMLInputElement
, HTMLIsIndexElement
, HTMLLabelElement
, HTMLLegendElement
, HTMLLIElement
, HTMLLinkElement
, HTMLMapElement
, HTMLMenuElement
, HTMLMetaElement
, HTMLModElement
, HTMLObjectElement
, HTMLOListElement
, HTMLOptGroupElement
, HTMLOptionElement
, HTMLParagraphElement
, HTMLParamElement
, HTMLPreElement
, HTMLQuoteElement
, HTMLScriptElement
, HTMLSelectElement
, HTMLStyleElement
, HTMLTableCaptionElement
, HTMLTableCellElement
, HTMLTableColElement
, HTMLTableElement
, HTMLTableRowElement
, HTMLTableSectionElement
, HTMLTextAreaElement
, HTMLTitleElement
, HTMLUListElement
, Notation
, ProcessingInstruction
, Text


public interface Node
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 Attr.name |
same as
Attr.value |
null |
CDATASection |
"#cdata-section" |
same as CharacterData.data, the
content of the CDATA Section |
null |
Comment |
"#comment" |
same as CharacterData.data, the
content of the comment |
null |
Document |
"#document" |
null |
null |
DocumentFragment |
"#document-fragment" |
null |
null |
DocumentType |
same as
DocumentType.name |
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 ProcessingInstruction.target |
same as
ProcessingInstruction.data |
null |
Text |
"#text" |
same as CharacterData.data, the content
of the text node |
null |
See also the Document Object Model (DOM) Level 3 Core Specification.
| Field Summary | |
|---|---|
static short |
ATTRIBUTE_NODE
The node is an Attr. |
static short |
CDATA_SECTION_NODE
The node is a CDATASection. |
static short |
COMMENT_NODE
The node is a Comment. |
static short |
DOCUMENT_FRAGMENT_NODE
The node is a DocumentFragment. |
static short |
DOCUMENT_NODE
The node is a Document. |
static short |
DOCUMENT_POSITION_CONTAINED_BY
The node is contained by the reference node. |
static short |
DOCUMENT_POSITION_CONTAINS
The node contains the reference node. |
static short |
DOCUMENT_POSITION_DISCONNECTED
The two nodes are disconnected. |
static short |
DOCUMENT_POSITION_FOLLOWING
The node follows the reference node. |
static short |
DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC
The determination of preceding versus following is implementation-specific. |
static short |
DOCUMENT_POSITION_PRECEDING
The second node precedes the reference node. |
static short |
DOCUMENT_TYPE_NODE
The node is a DocumentType. |
static short |
ELEMENT_NODE
The node is an Element. |
static short |
ENTITY_NODE
The node is an Entity. |
static short |
ENTITY_REFERENCE_NODE
The node is an EntityReference. |
static short |
NOTATION_NODE
The node is a Notation. |
static short |
PROCESSING_INSTRUCTION_NODE
The node is a ProcessingInstruction. |
static short |
TEXT_NODE
The node is a Text node. |
| Method Summary | |
|---|---|
Node |
appendChild
Adds the node newChild to the end of the list of children
of this node. |
Node |
cloneNode
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. |
short |
compareDocumentPosition
Compares the reference node, i.e. |
NamedNodeMap |
getAttributes
A NamedNodeMap containing the attributes of this node (if
it is an Element) or null otherwise. |
String |
getBaseURI
The absolute base URI of this node or null if the
implementation wasn't able to obtain an absolute URI. |
NodeList |
getChildNodes
A NodeList that contains all children of this node. |
Object |
getFeature
This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in . |
Node |
getFirstChild
The first child of this node. |
Node |
getLastChild
The last child of this node. |
String |
getLocalName
Returns the local part of the qualified name of this node. |
String |
getNamespaceURI
The namespace URI of this node, or null if it is
unspecified (see ). |
Node |
getNextSibling
The node immediately following this node. |
String |
getNodeName
The name of this node, depending on its type; see the table above. |
short |
getNodeType
A code representing the type of the underlying object, as defined above. |
String |
getNodeValue
The value of this node, depending on its type; see the table above. |
Document |
getOwnerDocument
The Document object associated with this node. |
Node |
getParentNode
The parent of this node. |
String |
getPrefix
The namespace prefix of this node, or null if it is
unspecified. |
Node |
getPreviousSibling
The node immediately preceding this node. |
String |
getTextContent
This attribute returns the text content of this node and its descendants. |
Object |
getUserData
Retrieves the object associated to a key on a this node. |
boolean |
hasAttributes
Returns whether this node (if it is an element) has any attributes. |
boolean |
hasChildNodes
Returns whether this node has any children. |
Node |
insertBefore
Inserts the node newChild before the existing child node
refChild. |
boolean |
isDefaultNamespace
This method checks if the specified namespaceURI is the
default namespace or not. |
boolean |
isEqualNode
Tests whether two nodes are equal. |
boolean |
isSameNode
Returns whether this node is the same node as the given one. |
boolean |
isSupported
Tests whether the DOM implementation implements a specific feature and that feature is supported by this node, as specified in . |
String |
lookupNamespaceURI
Look up the namespace URI associated to the given prefix, starting from this node. |
String |
lookupPrefix
Look up the prefix associated to the given namespace URI, starting from this node. |
void |
normalize
Puts all Text nodes in the full depth of the sub-tree
underneath this Node, including attribute nodes, 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. |
Node |
removeChild
Removes the child node indicated by oldChild from the list
of children, and returns it. |
Node |
replaceChild
Replaces the child node oldChild with newChild
in the list of children, and returns the oldChild node. |
void |
setNodeValue
The value of this node, depending on its type; see the table above. |
void |
setPrefix
The namespace prefix of this node, or null if it is
unspecified. |
void |
setTextContent |