Package | dom.tr.traversal |
Interface | public interface NodeIterator |
Introduced in: | DOM 2 Core |
NodeIterator
can be created using the createNodeIterator()
method of the Document
object, as follows:
var nodeIterator = document.createNodeIterator();
See also
Property | Defined By | ||
---|---|---|---|
DOM 2 TR expandEntityReferences : Boolean [read-only]
Returns a flag indicating whether or not the children of entity reference nodes are visible to the NodeIterator. | NodeIterator | ||
DOM 2 TR filter : NodeFilter [read-only]
Returns an object with a method acceptNode(node). | NodeIterator | ||
Non-Standard pointerBeforeReferenceNode : Boolean [read-only]
A Boolean value that indicates whether the NodeIterator is anchored before (if this value is true) or after (if this value is false) the anchor node indicated by the referenceNode property. | NodeIterator | ||
Non-Standard referenceNode : Node [read-only]
Returns the node to which the iterator is anchored; as new nodes are inserted, the iterator remains anchored to the reference node as specified by this property. | NodeIterator | ||
DOM 2 TR root : Node [read-only]
Returns the node that is the root of what the NodeIterator traverses. | NodeIterator | ||
DOM 2 TR whatToShow : Number [read-only]
Returns a number signifying what types of nodes should be returned by the NodeIterator. | NodeIterator |
Method | Defined By | ||
---|---|---|---|
DOM 2 TR detach():void
Detaches the NodeIterator from the set over which it iterates, releasing any resources used by the set
and setting the iterator's state to INVALID. | NodeIterator | ||
Returns the next node in the set represented by the NodeIterator and advances the position of the iterator within the set. | NodeIterator | ||
Returns the previous node in the set and moves the position of the NodeIterator backwards in the set. | NodeIterator |
DOM 2 TR expandEntityReferences | property |
expandEntityReferences:Boolean
[read-only] Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0b 1.0 2.0 9.62 10.0a |
Introduced in: | DOM 2 Core |
Returns a flag indicating whether or not the children of entity reference nodes are visible to the NodeIterator.
If this value is false, the children of entity reference nodes (as well as all of their descendants) are rejected. This takes precedence over the whatToShow value and the filter.
public function get expandEntityReferences():Boolean
See also
var nodeIterator = document.createNodeIterator( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } }, false ); expand = nodeIterator.expandEntityReferences;
DOM 2 TR filter | property |
filter:NodeFilter
[read-only] Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0b 1.0 2.0 9.62 10.0a |
Introduced in: | DOM 2 Core |
Returns an object with a method acceptNode(node). This is the NodeFilter used to screen nodes.
Note: When creating the NodeIterator, the filter object is passed in as the third parameter, and the object method acceptNode(node) is called on every single node to determine whether or not to accept it. This function should return the constant NodeFilter.FILTER_ACCEPT for cases when the node should be accepted and NodeFilter.FILTER_REJECT for cases when the node should be rejected.
public function get filter():NodeFilter
See also
var nodeIterator = document.createNodeIterator( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } }, false ); nodeFilter = nodeIterator.filter
pointerBeforeReferenceNode | property |
pointerBeforeReferenceNode:Boolean
[read-only] Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0b 1.0 2.0 9.62 10.0a |
Non-standard (Mozilla)
A Boolean value that indicates whether the NodeIterator is anchored before (if this value is true) or after (if this value is false) the anchor node indicated by the referenceNode property.
Note: This property was introduced by WebKit and is used for testing; it can also be used by debuggers. It is not part of the DOM specification.
public function get pointerBeforeReferenceNode():Boolean
See also
var nodeIterator = document.createNodeIterator( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } }, false ); flag = nodeIterator.pointerBeforeReferenceNode;
referenceNode | property |
referenceNode:Node
[read-only] Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0b 1.0 2.0 9.62 10.0a |
Non-standard (Mozilla)
Returns the node to which the iterator is anchored; as new nodes are inserted, the iterator remains anchored to the reference node as specified by this property.
Note: This property was introduced by WebKit and is used for testing; it can also be used by debuggers. It is not part of the DOM specification.
public function get referenceNode():Node
See also
var nodeIterator = document.createNodeIterator( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } }, false ); node = nodeIterator.referenceNode;
DOM 2 TR root | property |
root:Node
[read-only] Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0b 1.0 2.0 9.62 10.0a |
Introduced in: | DOM 2 Core |
Returns the node that is the root of what the NodeIterator traverses.
public function get root():Node
See also
var nodeIterator = document.createNodeIterator( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } }, false ); root = nodeIterator.root; // document.body in this case
DOM 2 TR whatToShow | property |
whatToShow:Number
[read-only] Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0b 1.0 2.0 9.62 10.0a |
Introduced in: | DOM 2 Core |
Returns a number signifying what types of nodes should be returned by the NodeIterator.
The available set of constants is defined in the NodeFilter interface. Nodes not accepted by whatToShow will be skipped, but their children may still be considered. Note that this skip takes precedence over the filter, if any.
public function get whatToShow():Number
See also
var nodeIterator = document.createNodeIterator( document.body, NodeFilter.SHOW_ELEMENT + NodeFilter.SHOW_COMMENT + NodeFilter.SHOW_TEXT, { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } }, false ); if((nodeIterator.whatToShow == NodeFilter.SHOW_ALL) || (nodeIterator.whatToShow % (NodeFilter.SHOW_COMMENT)) >= NodeFilter.SHOW_COMMENT) { // nodeIterator will show comments }
DOM 2 TR detach | () | method |
public function detach():void
Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0b 1.0 2.0 9.62 10.0a |
Introduced in: | DOM 2 Core |
Detaches the NodeIterator from the set over which it iterates, releasing any resources used by the set and setting the iterator's state to INVALID.
Once this method has been called, calls to other methods on NodeIterator will raise the INVALID_STATE_ERR exception.
See also
var nodeIterator = document.createNodeIterator( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } }, false ); nodeIterator.detach(); // detaches the iterator nodeIterator.nextNode(); // throws an INVALID_STATE_ERR exception
DOM 2 TR nextNode | () | method |
public function nextNode():Node
Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0b 1.0 2.0 9.62 10.0a |
Introduced in: | DOM 2 Core |
Returns the next node in the set represented by the NodeIterator and advances the position of the iterator within the set. The first call to nextNode() returns the first node in the set.
ReturnsNode — The next Node in the set being iterated over, or null if there are no more members in that set.
|
DOMException — INVALID_STATE_ERR: Raised if this method is called after the detach method was invoked.
|
See also
var nodeIterator = document.createNodeIterator( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } }, false ); currentNode = nodeIterator.nextNode(); // returns the next node
DOM 2 TR previousNode | () | method |
public function previousNode():Node
Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0b 1.0 2.0 9.62 10.0a |
Introduced in: | DOM 2 Core |
Returns the previous node in the set and moves the position of the NodeIterator backwards in the set.
This method returns null when the current node is the first node in the set.
ReturnsNode — The previous Node in the set being iterated over, or null if there are no more members in that set.
|
DOMException — INVALID_STATE_ERR: Raised if this method is called after the detach method was invoked.
|
See also
var nodeIterator = document.createNodeIterator( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } }, false ); currentNode = nodeIterator.nextNode(); // returns the next node previousNode = nodeIterator.previousNode(); // same result, since we backtracked to the previous node