Represents the result of the createNodeIterator method as an ordered list.
Note: The NodeIterator object is supported in Internet Explorer from version 9.The elements of the ordered list refer to the nodes in the document that fulfill the conditions specified for the createNodeIterator method. An element (element1) precedes another element (element2) in the ordered list if and only if the node referred to by the element1 precedes the node referred to by the element2 in the document tree.
The root, whatToShow, filter and expandEntityReferences properties of the NodeIterator object retrieve the settings that were specified earlier for the createNodeIterator method to create the NodeIterator object. The other members can be used to iterate through the result list.The createTreeWalker method and the TreeWalker object are similar to the createNodeIterator method and the NodeIterator object. The main difference is that the TreeWalker object represents the result as a tree not as an ordered list.
Methods that return the object:
|||object.createNodeIterator (rootNode, nodeType, filterFunction, entityRefExpansion)|
|Returns a Boolean value that indicates whether the children of entity reference nodes are visible to the NodeIterator or TreeWalker object.|
|Returns the filtering that function belongs to the NodeIterator or TreeWalker object.|
|Returns the root element that was used to create the NodeIterator or TreeWalker object.|
|Returns an integer that identifies the types of nodes that can be shown by the current NodeIterator or TreeWalker object.|
|detach||Releases the current NodeIterator object and puts the iterator into the invalid state.|
|nextNode||Finds the next node relative to the current node in the ordered list represented by the current NodeIterator object or in the tree represented by the current TreeWalker object. If it exists, it will be made the current node and returned, else the current node is retained and null is returned.|
|previousNode||Finds the previous node relative to the current node in the ordered list represented by the current NodeIterator object or in the tree represented by the current TreeWalker object. If it exists, it will be made the current node and returned, else the current node is retained and null is returned.|
Example HTML code 1:
This example shows how to iterate through span elements with the NodeIterator object:
Did you find this example helpful?
User Contributed Comments