XPathResult Class

https://dom.spec.whatwg.org/#interface-xpathresult (https://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#XPathResult)

public sealed class XPathResult

Properties

NameDescription
BooleanValueGets the boolean of the result; throws a TypeError when the result is not a boolean.
InvalidIteratorStateWhether the document was modified since the result was created, which invalidates iterators.
NumberValueGets the number of the result; throws a TypeError when the result is not a number.
ResultTypeGets the type of the result, one of the *_TYPE constants.
SingleNodeValueGets the node of the result, or null when none matched; throws a TypeError when the result is not a single node.
SnapshotLengthGets the number of nodes of the snapshot; throws a TypeError when the result is not a snapshot.
StringValueGets the string of the result; throws a TypeError when the result is not a string.

BooleanValue

XPathApi.cs

Gets the boolean of the result; throws a TypeError when the result is not a boolean.

public bool BooleanValue { get; }

InvalidIteratorState

XPathApi.cs

Whether the document was modified since the result was created, which invalidates iterators.

public bool InvalidIteratorState { get; }

NumberValue

XPathApi.cs

Gets the number of the result; throws a TypeError when the result is not a number.

public double NumberValue { get; }

ResultType

XPathApi.cs

Gets the type of the result, one of the *_TYPE constants.

public ushort ResultType { get; }

SingleNodeValue

XPathApi.cs

Gets the node of the result, or null when none matched; throws a TypeError when the result is not a single node.

public Node? SingleNodeValue { get; }

SnapshotLength

XPathApi.cs

Gets the number of nodes of the snapshot; throws a TypeError when the result is not a snapshot.

public uint SnapshotLength { get; }

StringValue

XPathApi.cs

Gets the string of the result; throws a TypeError when the result is not a string.

public string StringValue { get; }

Methods

NameDescription
IterateNext()Returns the next node of the iterator, or null at the end; throws an InvalidStateError when the document was modified.
SnapshotItem(uint)Returns the node of the snapshot at the given index, or null when the index is out of range.

IterateNext()

XPathApi.cs

Returns the next node of the iterator, or null at the end; throws an InvalidStateError when the document was modified.

public Node? IterateNext()

SnapshotItem(uint)

XPathApi.cs

Returns the node of the snapshot at the given index, or null when the index is out of range.

public Node? SnapshotItem(uint index)

Constants

NameDescription
AnyTypeThe type that lets the evaluation choose the natural type of the result.
AnyUnorderedNodeTypeA single node, any of the matching ones.
BooleanTypeA single boolean.
FirstOrderedNodeTypeA single node, the first matching one in document order.
NumberTypeA single number.
OrderedNodeIteratorTypeAn iterator over the nodes, in document order.
OrderedNodeSnapshotTypeA snapshot of the nodes, in document order.
StringTypeA single string.
UnorderedNodeIteratorTypeAn iterator over the nodes, in any order.
UnorderedNodeSnapshotTypeA snapshot of the nodes, in any order.

AnyType

The type that lets the evaluation choose the natural type of the result.

public const ushort AnyType = 0

AnyUnorderedNodeType

A single node, any of the matching ones.

public const ushort AnyUnorderedNodeType = 8

BooleanType

A single boolean.

public const ushort BooleanType = 3

FirstOrderedNodeType

A single node, the first matching one in document order.

public const ushort FirstOrderedNodeType = 9

NumberType

A single number.

public const ushort NumberType = 1

OrderedNodeIteratorType

An iterator over the nodes, in document order.

public const ushort OrderedNodeIteratorType = 5

OrderedNodeSnapshotType

A snapshot of the nodes, in document order.

public const ushort OrderedNodeSnapshotType = 7

StringType

A single string.

public const ushort StringType = 2

UnorderedNodeIteratorType

An iterator over the nodes, in any order.

public const ushort UnorderedNodeIteratorType = 4

UnorderedNodeSnapshotType

A snapshot of the nodes, in any order.

public const ushort UnorderedNodeSnapshotType = 6