Packagedom.tr.traversal
Interfacepublic interface DocumentTraversal
Implementors Document

Introduced in: DOM 2 Core 

Contains methods that create iterators and tree-walkers to traverse a node and its children in document order.

See also

MDC - Document
W3C - DOM Level 2 Traversal: DocumentTraversal


Public Methods
 MethodDefined By
  
DOM 2 TR createNodeIterator(root:Node, whatToShow:Number, filter:NodeFilter, entityReferenceExpansion:Boolean):NodeIterator
Create a new NodeIterator over the subtree rooted at the specified node.
DocumentTraversal
  
DOM 2 TR createTreeWalker(root:Node, whatToShow:Number, filter:NodeFilter, entityReferenceExpansion:Boolean):TreeWalker
Create a new TreeWalker over the subtree rooted at the specified node.
DocumentTraversal
Method Detail
DOM 2 TR createNodeIterator()method
public function createNodeIterator(root:Node, whatToShow:Number, filter:NodeFilter, entityReferenceExpansion:Boolean):NodeIterator

Product Versions : Internet Explorer 5.5 Internet Explorer 6.0 Internet Explorer 7.0 Internet Explorer 8.0 as IE7 Internet Explorer 8.0 as IE8 Firefox 2.0 Firefox 3.0 Firefox 3.5 Safari 3.0 Safari 3.1 Safari 4.0b Chrome 1.0 Chrome 2.0 Opera 9.62 Opera 10.0a
Introduced in: DOM 2 Core 

Create a new NodeIterator over the subtree rooted at the specified node.

Parameters

root:Node — The node which will be iterated together with its children. The iterator is initially positioned just before this node. The whatToShow flags and the filter, if any, are not considered when setting this position. The root must not be null.
 
whatToShow:Number — This flag specifies which node types may appear in the logical view of the tree presented by the iterator. These flags can be combined using OR.
 
filter:NodeFilter — The NodeFilter to be used with this TreeWalker, or null to indicate no filter.
 
entityReferenceExpansion:Boolean — The value of this flag determines whether entity reference nodes are expanded.

Returns
NodeIterator — The newly created NodeIterator.

Throws
DOMException — NOT_SUPPORTED_ERR: Raised if the specified root is null.

See also


Example
         var nodeIterator = document.createNodeIterator(
             document.body,
             NodeFilter.SHOW_ELEMENT,
             { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } },
             false
             );
         var nodeList = new Array();
         var currentNode;
         
         while (currentNode = nodeIterator.nextNode()) {
             nodeList.push(currentNode);
         }
DOM 2 TR createTreeWalker()method 
public function createTreeWalker(root:Node, whatToShow:Number, filter:NodeFilter, entityReferenceExpansion:Boolean):TreeWalker

Product Versions : Internet Explorer 5.5 Internet Explorer 6.0 Internet Explorer 7.0 Internet Explorer 8.0 as IE7 Internet Explorer 8.0 as IE8 Firefox 2.0 Firefox 3.0 Firefox 3.5 Safari 3.0 Safari 3.1 Safari 4.0b Chrome 1.0 Chrome 2.0 Opera 9.62 Opera 10.0a
Introduced in: DOM 2 Core 

Create a new TreeWalker over the subtree rooted at the specified node.

Parameters

root:Node — The node which will serve as the root for the TreeWalker. The whatToShow flags and the NodeFilter are not considered when setting this value; any node type will be accepted as the root. The currentNode of the TreeWalker is initialized to this node, whether or not it is visible. The root functions as a stopping point for traversal methods that look upward in the document structure, such as parentNode and nextNode. The root must not be null.
 
whatToShow:Number — This flag specifies which node types may appear in the logical view of the tree presented by the tree-walker. These flags can be combined using OR.
 
filter:NodeFilter — The NodeFilter to be used with this TreeWalker, or null to indicate no filter.
 
entityReferenceExpansion:Boolean — If this flag is false, the contents of EntityReference nodes are not presented in the logical view.

Returns
TreeWalker — The newly created TreeWalker.

Throws
DOMException — NOT_SUPPORTED_ERR: Raised if the specified root is null.

See also


Example
         var treeWalker = document.createTreeWalker(
             document.body,
             NodeFilter.SHOW_ELEMENT,
             { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } },
             false
             );
         var nodeList = new Array();
         while(treeWalker.nextNode()) nodeList.push(treeWalker.currentNode);