AwaitedDOM/ XPathResult

The XPathResult interface represents the results generated by evaluating an XPath expression within the context of a given node. Since XPath expressions can result in a variety of result types, this interface makes it possible to determine and handle the type and value of the result.

Properties

.booleanValue
W3C

A boolean representing the value of the result if resultType is BOOLEAN_TYPE.

Type: Promise<boolean>

.invalidIteratorState
W3C

Signifies that the iterator has become invalid. It is true if resultType is UNORDERED_NODE_ITERATOR_TYPE or ORDERED_NODE_ITERATOR_TYPE and the document has been modified since this result was returned.

Type: Promise<boolean>

.numberValue
W3C

A number representing the value of the result if resultType is NUMBER_TYPE.

Type: Promise<number>

.resultType
W3C

A number code representing the type of the result, as defined by the type constants.

Type: Promise<number>

.singleNodeValue
W3C

A Node representing the value of the single node result, which may be null.

NOTE: The returned SuperNode will behave like all AwaitedDom SuperNodes: nothing will be retrieved until you await the node or child property.

 await result.singleNodeResult === null; // null if not present
 await result.singleNodeResult.textContent; // gets text

Type: SuperNode

.snapshotLength
W3C

The number of nodes in the result snapshot.

Type: Promise<number>

.stringValue
W3C

A string representing the value of the result if resultType is STRING_TYPE.

Type: Promise<string>

Methods

.iterateNext()
W3C

If the result is a node set, this method iterates over it and returns the next node from it or null if there are no more nodes.

NOTE: The iterated SuperNodes will behave like all AwaitedDom SuperNodes: nothing will be retrieved until you await the node or child property.

 await result.iterateNext() === null; // null if not present
 await result.iterateNext().textContent; // gets text

Returns: SuperNode

.snapshotItem(index)
W3C

Returns an item of the snapshot collection or null in case the index is not within the range of nodes. Unlike the iterator result, the snapshot does not become invalid, but may not correspond to the current document if it is mutated.

Arguments:

  • index number. Needs content.

Returns: SuperNode

Edit this page on GitHub