-
public interface DocumentTraversal
DocumentTraversal
contains methods that createNodeIterators
andTreeWalkers
to traverse a node and its children in document order (depth first, pre-order traversal, which is equivalent to the order in which the start tags occur in the text representation of the document). In DOMs which support the Traversal feature,DocumentTraversal
will be implemented by the same objects that implement the Document interface.See also the Document Object Model (DOM) Level 2 Traversal and Range Specification.
- Since:
- 9, DOM Level 2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description NodeIterator
createNodeIterator(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion)
Create a newNodeIterator
over the subtree rooted at the specified node.TreeWalker
createTreeWalker(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion)
Create a newTreeWalker
over the subtree rooted at the specified node.
-
-
-
Method Detail
-
createNodeIterator
NodeIterator createNodeIterator(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion) throws DOMException
Create a newNodeIterator
over the subtree rooted at the specified node.- Parameters:
root
- The node which will be iterated together with its children. TheNodeIterator
is initially positioned just before this node. ThewhatToShow
flags and the filter, if any, are not considered when setting this position. The root must not benull
.whatToShow
- This flag specifies which node types may appear in the logical view of the tree presented by theNodeIterator
. See the description ofNodeFilter
for the set of possibleSHOW_
values.These flags can be combined usingOR
.filter
- TheNodeFilter
to be used with thisNodeIterator
, ornull
to indicate no filter.entityReferenceExpansion
- The value of this flag determines whether entity reference nodes are expanded.- Returns:
- The newly created
NodeIterator
. - Throws:
DOMException
- NOT_SUPPORTED_ERR: Raised if the specifiedroot
isnull
.
-
createTreeWalker
TreeWalker createTreeWalker(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion) throws DOMException
Create a newTreeWalker
over the subtree rooted at the specified node.- Parameters:
root
- The node which will serve as theroot
for theTreeWalker
. ThewhatToShow
flags and theNodeFilter
are not considered when setting this value; any node type will be accepted as theroot
. ThecurrentNode
of theTreeWalker
is initialized to this node, whether or not it is visible. Theroot
functions as a stopping point for traversal methods that look upward in the document structure, such asparentNode
and nextNode. Theroot
must not benull
.whatToShow
- This flag specifies which node types may appear in the logical view of the tree presented by theTreeWalker
. See the description ofNodeFilter
for the set of possibleSHOW_
values.These flags can be combined usingOR
.filter
- TheNodeFilter
to be used with thisTreeWalker
, ornull
to indicate no filter.entityReferenceExpansion
- If this flag is false, the contents ofEntityReference
nodes are not presented in the logical view.- Returns:
- The newly created
TreeWalker
. - Throws:
DOMException
- NOT_SUPPORTED_ERR: Raised if the specifiedroot
isnull
.
-
-