Interface ElementTraversal
public interface ElementTraversal
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
Methods
Modifier and Type | Method | Description |
---|---|---|
int | getChildElementCount() | Returns the current number of child nodes of the element which are of the |
Element | getFirstElementChild() | Returns a reference to the first child node of the element which is of the |
Element | getLastElementChild() | Returns a reference to the last child node of the element which is of the |
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 | 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 |
Methods
getFirstElementChild
Element getFirstElementChild()
Returns a reference to the first child node of the element which is of the Element
type.
- Returns:
- a reference to an element child,
null
if the element has no child of theElement
type.
getLastElementChild
Element getLastElementChild()
Returns a reference to the last child node of the element which is of the Element
type.
- Returns:
- a reference to an element child,
null
if the element has no child of theElement
type.
getPreviousElementSibling
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:
- a reference to an element child,
null
if the element has no sibling node of theElement
type that comes before this one.
getNextElementSibling
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:
- a reference to an element child,
null
if the element has no sibling node of theElement
type that comes after this one.
getChildElementCount
int getChildElementCount()
Returns the current number of child nodes of the element which are of the Element
type.
- Returns:
- the number of element children, or
0
if the element has no element children.
© 1993, 2020, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/ElementTraversal.html