Object: NodeIterator
Availability
|
BlackBerry®
Device Software version 4.6 or later
|
The NodeIterator object enables you to navigate up and down through a flat representation of the document tree. This object is similar to the TreeWalker objects, except that TreeWalker presents nodes in a tree-oriented view, rather than the list view presented by NodeIterator.
Create a NodeIterator using Document.createNodeIterator().
NodeIterator properties
Property name
|
Type
|
Description
|
Status
|
Availability
|
expandEntityReferences
|
boolean
|
Returns whether or not the NodeIterator
expands the entity references it encounters as it traverses the document.
|
read only
|
4.6 or later
|
filter
|
NodeFilter
|
Returns the NodeFilter used to filter nodes for traversal.
|
read only
|
4.6 or later
|
root
|
Node
|
Returns the Node at which the NodeIterator
begins traversing the document.
|
read only
|
4.6 or later
|
whatToShow
|
unsigned long
|
Returns which node types are presented by the NodeIterator. The value may be one or more of:
- 0xFFFFFFFF = SHOW_ALL
- 0x00000001 = SHOW_ELEMENT
- 0x00000002 = SHOW_ATTRIBUTE
- 0x00000004 = SHOW_TEXT
- 0x00000008 = SHOW_CDATA_SECTION
- 0x00000010 = SHOW_ENTITY_REFERENCE
- 0x00000020 = SHOW _ENTITY
- 0x00000040 = SHOW_PROCESSING_INSTRUCTION
- 0x00000080 = SHOW_COMMENT
- 0x00000100 = SHOW_DOCUMENT
- 0x00000200 = SHOW_DOCUMENT_TYPE
- 0x00000400 = SHOW_DOCUMENT_FRAGMENT
- 0x00000800 = SHOW_NOTATION
Multiple values may be specified using a bitwise OR.
Note that because attributes, entities, and notations are not the child of any other node, they never appear in the NodeIterator
’s logical view unless they are defined as the root of the NodeIterator
object. If the respective object is not defined as the root, then SHOW_ATTRIBUTE, SHOW_ENTITY, and SHOW NOTATION have no meaning.
|
read only
|
4.6 or later
|
NodeIterator methods
Method name
|
Description
|
Availability
|
detach()
|
Detaches the NodeIterator from the set which it iterated over.
|
4.6 or later
|
nextNode()
|
Moves the NodeIterator to the next visible Node in the document order, relative to the current node.
|
4.6 or later
|
previousNode()
|
Moves the NodeIterator to the previous visible Node in the document order, relative to the current node.
|
4.6 or later
|
Method: NodeIterator.detach()
Availability
|
BlackBerry®
Device Software version 4.6 or later
|
Syntax
NodeIterator.detach()
Method: NodeIterator.nextNode()
Availability
|
BlackBerry®
Device Software version 4.6 or later
|
The nextNode() method moves the NodeIterator to the next visible Node in the document order, relative to the current node. The first call to this method after a NodeIterator is created returns the first Node in the set.
Syntax
NodeIterator.nextNode()
Return values
Returns the node, or null, if there is no node after the current node in the NodeIterator’s logical view.
Exceptions
Exception
|
Description
|
INVALID_STATE_ERR
|
This error is thrown if this method is called after the NodeIterator has been detached from the set that it iterated over.
|
Method: NodeIterator.previousNode()
Availability
|
BlackBerry®
Device Software version 4.6 or later
|
The
previousNode() method moves the
NodeIterator to the previous visible
Node in the document order, relative to the current node.
Syntax
NodeIterator.previousNode()
Return values
Returns the node, or null, if there is no node before the current node in the NodeIterator’s logical view.
Exceptions
Exception
|
Description
|
INVALID_STATE_ERR
|
This error is thrown if this method is called after the NodeIterator has been detached from the set that it iterated over.
|
Was this information helpful? Send us your comments.