Class XPathResult


class XPathResult
Container for XPath results.

See http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#XPathResult.

Authors:
Henrik Lindqvist <henrik.lindqvist@llamalab.com>
See also:
Defined in XPath.js

Property Summary
static read number ANY_TYPE
Result will be accessed unconverted as the expression returned it.
static read number ANY_UNORDERED_NODE_TYPE
Result will be accessed as a single node value, any of the resulting nodes.
static read number BOOLEAN_TYPE
Result will be accessed as boolean.
static read number FIRST_ORDERED_NODE_TYPE
Result will be accessed as a single node value, the first resulting node in document-ordered.
static read number NUMBER_TYPE
Convert result to number.
static read number ORDERED_NODE_ITERATOR_TYPE
Result will be accessed iteratively which must be document-ordered.
static read number ORDERED_NODE_SNAPSHOT_TYPE
Result will be accessed as a snapshot list of nodes which must be document-ordered.
static read number STRING_TYPE
Result will be accessed as a string.
static read number UNORDERED_NODE_ITERATOR_TYPE
Result will be accessed iteratively, node order insignificant.
static read number UNORDERED_NODE_SNAPSHOT_TYPE
Result will be accessed as a snapshot list of nodes, node order insignificant.
read boolean booleanValue
Resulting boolean.
read boolean invalidIteratorState
Signifies that the iterator has become invalid.
read number numberValue
Resulting number.
read object singleNodeValue
The value of this single node result, maybe undefined.
read number snapshotLength
The number of nodes in the result snapshot.
read string stringValue
Resulting string.
read object value
Unconverted result as returned by our internal evaluator.

Function Summary
object iterateNext()
Iterates and returns the next node from the resuling nodes.
object snapshotItem(number i)
Returns the indexth item in the snapshot collection.

Property Details

property static read number ANY_TYPE

Result will be accessed unconverted as the expression returned it.

property static read number ANY_UNORDERED_NODE_TYPE

Result will be accessed as a single node value, any of the resulting nodes.

This is equal to FIRST_ORDERED_NODE_TYPE since the result is always document-ordered.

See also:

property static read number BOOLEAN_TYPE

Result will be accessed as boolean.
See also:

property static read number FIRST_ORDERED_NODE_TYPE

Result will be accessed as a single node value, the first resulting node in document-ordered.
See also:

property static read number NUMBER_TYPE

Convert result to number.

property static read number ORDERED_NODE_ITERATOR_TYPE

Result will be accessed iteratively which must be document-ordered.
See also:

property static read number ORDERED_NODE_SNAPSHOT_TYPE

Result will be accessed as a snapshot list of nodes which must be document-ordered.

property static read number STRING_TYPE

Result will be accessed as a string.
See also:

property static read number UNORDERED_NODE_ITERATOR_TYPE

Result will be accessed iteratively, node order insignificant.

This is equal to ORDERED_NODE_ITERATOR_TYPE since the result is always document-ordered.

See also:

property static read number UNORDERED_NODE_SNAPSHOT_TYPE

Result will be accessed as a snapshot list of nodes, node order insignificant.

This is equal to ORDERED_NODE_SNAPSHOT_TYPE since the result is always document-ordered.


property read boolean booleanValue

Resulting boolean.
See also:

property read boolean invalidIteratorState

Signifies that the iterator has become invalid.

property read number numberValue

Resulting number.
See also:

property read object singleNodeValue

The value of this single node result, maybe undefined.

property read number snapshotLength

The number of nodes in the result snapshot.

property read string stringValue

Resulting string.
See also:

property read object value

Unconverted result as returned by our internal evaluator.

This is a non-standard property which is set to the raw unconverted result from our expression evaluator. It’s of the type number, string, boolean or an Array with nodes depending on expression. If you prefer to work with arrays instead of XPathResult.snapshotItem You can check for this property and use it directly.

Example

 function selectNodes (expr) {
   // Cross-browser safe way of selecting nodes and return an Array 
   var r = document.evaluate('//LI', document, null, 7, null);
   if (typeof r.value != 'undefined') return r.value;
   var a = [];
   for (var i = r.snapshotLength; --i >= 0; a[i] = r.snapshotItem(i));
   return a;
 }
 
See also:

Function Details

function iterateNext

object iterateNext()
Iterates and returns the next node from the resuling nodes.
Returns:
a Node, or undefined if there are no more nodes.

function snapshotItem

object snapshotItem(number i)
Returns the indexth item in the snapshot collection.
Parameters:
i - index of resuling node to return.
Returns:
the Node, at provided index or undefined if invalid.