Top Description Methods
org.w3c.dom

public Interface ElementTraversal

Known Direct Implementers
com.sun.org.apache.xerces.internal.dom.ElementImpl

The ElementTraversal interface is a set of read-only attributes which allow an author to easily navigate between elements in a document.

In conforming implementations of Element Traversal, all objects that implement Element must also implement the ElementTraversal interface. Four of the methods, getFirstElementChild, getLastElementChild, getPreviousElementSibling, and getNextElementSibling, each provides a live reference to another element with the defined relationship to the current element, if the related element exists. The fifth method, getChildElementCount, exposes the number of child elements of an element, for preprocessing before navigation.

Since
9
See Also
Element Traversal Specification

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the number of element children, or 0 if the element has no element children.
getChildElementCount
()

Returns the current number of child nodes of the element which are of the Element type.

public Element

Returns:

a reference to an element child, null if the element has no child of the Element type.
getFirstElementChild
()

Returns a reference to the first child node of the element which is of the Element type.

public Element

Returns:

a reference to an element child, null if the element has no child of the Element type.
getLastElementChild
()

Returns a reference to the last child node of the element which is of the Element type.

public Element

Returns:

a reference to an element child, null if the element has no sibling node of the Element type that comes after this one.
getNextElementSibling
()

Returns a reference to the sibling node of the element which most immediately follows the element in document order, and which is of the Element type.

public Element

Returns:

a reference to an element child, null if the element has no sibling node of the Element type that comes before this one.
getPreviousElementSibling
()

Returns a reference to the sibling node of the element which most immediately precedes the element in document order, and which is of the Element type.

Method Detail

getChildElementCountback to summary
public int getChildElementCount()

Returns the current number of child nodes of the element which are of the Element type.

Returns:int

the number of element children, or 0 if the element has no element children.

getFirstElementChildback to summary
public Element getFirstElementChild()

Returns a reference to the first child node of the element which is of the Element type.

Returns:Element

a reference to an element child, null if the element has no child of the Element type.

getLastElementChildback to summary
public Element getLastElementChild()

Returns a reference to the last child node of the element which is of the Element type.

Returns:Element

a reference to an element child, null if the element has no child of the Element type.

getNextElementSiblingback to summary
public Element getNextElementSibling()

Returns a reference to the sibling node of the element which most immediately follows the element in document order, and which is of the Element type.

Returns:Element

a reference to an element child, null if the element has no sibling node of the Element type that comes after this one.

getPreviousElementSiblingback to summary
public Element getPreviousElementSibling()

Returns a reference to the sibling node of the element which most immediately precedes the element in document order, and which is of the Element type.

Returns:Element

a reference to an element child, null if the element has no sibling node of the Element type that comes before this one.