Interface Node

Node
All Known Implementing Classes:
CharacterData, Comment, Document, Element, HTMLDocument, HTMLElement, HTMLFormElement, HTMLIFrameElement, HTMLInputElement, HTMLLIElement, HTMLScriptElement, HTMLTableElement, HTMLTableRowElement, Text, f_abstractEntry, f_abstractList, f_additionalInformation, f_box, f_button, f_calendar, f_card, f_cardBox, f_checkButton, f_combo, f_comboGrid, f_component, f_componentsGrid, f_componentsList, f_compositeNumEntry, f_customButton, f_dataGrid, f_dataGridPopup, f_dateChooser, f_dateEntry, f_eventTarget, f_expandBar, f_externalBox, f_fieldSet, f_filtredComponent, f_grid, f_helpButton, f_helpMessageZone, f_hiddenValue, f_hyperLink, f_image, f_imageButton, f_imageCheckButton, f_imageCombo, f_imagePagerButton, f_imageRadioButton, f_imageResetButton, f_imageSubmitButton, f_input, f_itemsList, f_itemsToolFolder, f_keyEntry, f_keyLabel, f_lineBreak, f_list, f_menu, f_menuBar, f_menuBarBase, f_menuBase, f_message, f_messageFieldSet, f_messages, f_numberEntry, f_pager, f_passwordEntry, f_progressBar, f_progressIndicator, f_radioButton, f_resetButton, f_ruler, f_scheduler, f_spinner, f_styledMessage, f_styledText, f_submitButton, f_suggestTextEntry, f_tab, f_tabbedPane, f_text, f_textArea, f_textEditor, f_textEditorCombo, f_textEditorImageButton, f_textEntry, f_timeEntry, f_toolBar, f_toolFolder, f_tree

public 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.

Interface nodeName nodeValue attributes
Attr name of attribute value of attribute null
CDATASection #cdata-section content of the CDATA Section null
Comment #comment content of the comment null
Document #document null null
DocumentFragment #document-fragment null null
DocumentType document type name null null
Element tag name null NamedNodeMap
Entity entity name null null
EntityReference name of entity referenced null null
Notation notation name null null
ProcessingInstruction target entire content excluding the target null
Text #text content of the text node null


Field Summary
 NodeList childNodes
          A NodeList that contains all children of this node.
 Node firstChild
          The first child of this node.
 Node lastChild
          The last child of this node.
 Node nextSibling
          The node immediately following this node.
 String nodeName
          The name of this node, depending on its type; see the table above.
 Number nodeType
          A code representing the type of the underlying object, as defined above.
 String nodeValue
          The value of this node, depending on its type; see the table above.
 Document ownerDocument
          The Document object associated with this node.
 Node parentNode
           
 Node previousSibling
          The node immediately preceding this node.
 
Method Summary
 Node appendChild(Node newChild)
          Adds the node newChild to the end of the list of children of this node.
 boolean hasChildNodes()
          Returns whether this node has any children.
 Node insertBefore(Node newChild, Node refChild)
          Inserts the node newChild before the existing child node refChild.
 Node removeChild(Node oldChild)
          Removes the child node indicated by oldChild from the list of children, and returns it.
 Node replaceChild(Node newChild, Node oldChild)
          Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.
 

Field Detail

previousSibling

final Node previousSibling
The node immediately preceding this node. If there is no such node, this returns null.


parentNode

final Node parentNode

firstChild

final Node firstChild
The first child of this node. If there is no such node, this returns null.


nodeValue

final String nodeValue
The value of this node, depending on its type; see the table above. When it is defined to be null, setting it has no effect.


nodeName

final String nodeName
The name of this node, depending on its type; see the table above.


childNodes

final NodeList childNodes
A NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes.


nodeType

final Number nodeType
A code representing the type of the underlying object, as defined above.


ownerDocument

final Document ownerDocument
The Document object associated with this node. This is also the Document object used to create new nodes. When this node is a Document or a DocumentType which is not used with any Document yet, this is null.


nextSibling

final Node nextSibling
The node immediately following this node. If there is no such node, this returns null.


lastChild

final Node lastChild
The last child of this node. If there is no such node, this returns null.

Method Detail

removeChild

final Node removeChild(Node oldChild)
Removes the child node indicated by oldChild from the list of children, and returns it.

Parameters:
oldChild - The node being removed.
Returns:
The node removed.

insertBefore

final Node insertBefore(Node newChild,
                        Node refChild)
Inserts the node newChild before the existing child node refChild. If refChild is null, insert newChild at the end of the list of children. If newChild is a DocumentFragment object, all of its children are inserted, in the same order, before refChild. If the newChild is already in the tree, it is first removed.

Parameters:
newChild - The node to insert.
refChild - The reference node, i.e., the node before which the new node must be inserted.
Returns:
The node being inserted.

hasChildNodes

final boolean hasChildNodes()
Returns whether this node has any children.

Returns:
true if this node has any children, false otherwise.

appendChild

final Node appendChild(Node newChild)
Adds the node newChild to the end of the list of children of this node. If the newChild is already in the tree, it is first removed.

Parameters:
newChild - The node to add. If it is a DocumentFragment object, the entire contents of the document fragment are moved into the child list of this node
Returns:
The node added

replaceChild

final Node replaceChild(Node newChild,
                        Node oldChild)
Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node. If newChild is a DocumentFragment object, oldChild is replaced by all of the DocumentFragment children, which are inserted in the same order. If the newChild is already in the tree, it is first removed.

Parameters:
newChild - The new node to put in the child list.
oldChild - The node being replaced in the list.
Returns:
The node replaced.