Help Center

Local Navigation

Object: TreeWalker

Availability

BlackBerry® Device Software version 4.6 or later

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

currentNode

Node

Specifies the current position of the TreeWalker.

writable

DOM 2 Traversal

4.6 or later

expandEntityReferences

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

filter

NodeFilter

Returns the NodeFilter used to filter nodes for traversal.

read only

DOM 2 Traversal

4.6 or later

root

Node

Returns the Node at which the TreeWalker begins traversing the document.

read only

DOM 2 Traversal

4.6 or later

whatToShow

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

firstChild()

Moves the TreeWalker to the first visible child of the current node.

DOM 2 Traversal

4.6 or later

lastChild()

Moves the TreeWalker to the last visible child of the current node.

DOM 2 Traversal

4.6 or later

nextNode()

Moves the TreeWalker to the next visible node in the document order, relative to the current node.

DOM 2 Traversal

4.6 or later

nextSibling()

Moves the TreeWalker to the next sibling of the current node.

DOM 2 Traversal

4.6 or later

parentNode()

Moves the TreeWalker to the closest visible ancestor node of the current node.

DOM 2 Traversal

4.6 or later

previousNode()

Moves the TreeWalker to the previous visible node in the document order, relative to the current node.

DOM 2 Traversal

4.6 or later

previousSibling()

Moves the TreeWalker to the previous sibling of the current node.

DOM 2 Traversal

4.6 or later

Next topic: Window API
Previous topic: NodeIterator methods

Was this information helpful? Send us your comments.