Object: TreeWalker
The TreeWalker object enables you to navigate the document tree or subtree. This object is similar to the NodeIterator objects, except that TreeWalker presents nodes in a tree-oriented view, rather than the list view presented by NodeIterator. This allows you to use TreeWalker to navigate directly to a parent or child, rather than simply up and down in the list using NodeIterator.
Create a TreeWalker using Document.createTreeWalker().
TreeWalker properties
|
Property name |
Type |
Description |
Status |
Support level |
Availability |
|---|---|---|---|---|---|
|
Specifies the current position of the TreeWalker. |
writable |
DOM 2 Traversal |
4.6 or later |
||
|
boolean |
Returns whether or not the TreeWalker expands the entity references it encounters as it traverses the document. |
read only |
DOM 2 Traversal |
4.6 or later |
|
|
Returns the NodeFilter used to filter nodes for traversal. |
read only |
DOM 2 Traversal |
4.6 or later |
||
|
Returns the Node at which the TreeWalker begins traversing the document. |
read only |
DOM 2 Traversal |
4.6 or later |
||
|
unsigned long |
Returns which node types are presented by the TreeWalker, represented by one or more NodeFilter constants. Multiple values may be specified using a bitwise OR. |
read only |
DOM 2 Traversal |
4.6 or later |
TreeWalker methods
|
Method name |
Description |
Support level |
Availability |
|---|---|---|---|
|
Moves the TreeWalker to the first visible child of the current node. |
DOM 2 Traversal |
4.6 or later |
|
|
Moves the TreeWalker to the last visible child of the current node. |
DOM 2 Traversal |
4.6 or later |
|
|
Moves the TreeWalker to the next visible node in the document order, relative to the current node. |
DOM 2 Traversal |
4.6 or later |
|
|
Moves the TreeWalker to the next sibling of the current node. |
DOM 2 Traversal |
4.6 or later |
|
|
Moves the TreeWalker to the closest visible ancestor node of the current node. |
DOM 2 Traversal |
4.6 or later |
|
|
Moves the TreeWalker to the previous visible node in the document order, relative to the current node. |
DOM 2 Traversal |
4.6 or later |
|
|
Moves the TreeWalker to the previous sibling of the current node. |
DOM 2 Traversal |
4.6 or later |