NodeEnumeratorObject

A NodeEnumeratorObject is a more efficient way to operate on a list of nodes. Instead of building the entire list all at once, the enumerator grabs only one node at a time as needed. If you find what you are looking for halfway through the list, you can abandon the enumerator. Properties and methods that return an Array of node objects must build the entire array immediately, whether you access the items at the end of the array or not.

The enumerator starts with a null Current value. You must call MoveNext() to advance the enumerator to the first node in the list.

Note:

A good practice is to use the With methods like AncestorsWith or SiblingsWith methods when you need to find only a few nodes out of all possible matches and need to iterate the list only one time. If you need to cycle over the list of ancestor nodes multiple times or you know you will need most or all of the ancestors, then an enumerator may be faster.

Table 31. NodeEnumeratorObject Methods

Name

Description

GetCurrent()

The current node (either a NodeObject or LocalNodeObject depending on the context).

MoveNext()

Advances the enumerator to the next node. Returns False if there are no more nodes to enumerate.