Our volunteers haven't translated this article into عربي yet. Join us and help get the job done!
You can also read the article in English (US).

The XPathResult interface represents the results generated by evaluating an XPath 1.0 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

XPathResult.booleanValueRead only
boolean
XPathResult.invalidIteratorStateRead only
boolean
XPathResult.numberValueRead only
float
XPathResult.resultTypeRead only
integer (short)
XPathResult.singleNodeValueRead only
Node
XPathResult.snapshotLengthRead only
Integer
XPathResult.stringValueRead only
String

Methods

XPathResult.iterateNext()
...
XPathResult.snapshotItem()
...

Constants

Result Type Defined Constant Value Description
ANY_TYPE 0 A result set containing whatever type naturally results from evaluation of the expression. Note that if the result is a node-set then UNORDERED_NODE_ITERATOR_TYPE is always the resulting type.
NUMBER_TYPE 1 A result containing a single number. This is useful for example, in an XPath expression using the count() function.
STRING_TYPE 2 A result containing a single string.
BOOLEAN_TYPE 3 A result containing a single boolean value. This is useful for example, in an XPath expression using the not() function.
UNORDERED_NODE_ITERATOR_TYPE 4 A result node-set containing all the nodes matching the expression. The nodes may not necessarily be in the same order that they appear in the document.
ORDERED_NODE_ITERATOR_TYPE 5 A result node-set containing all the nodes matching the expression. The nodes in the result set are in the same order that they appear in the document.
UNORDERED_NODE_SNAPSHOT_TYPE 6 A result node-set containing snapshots of all the nodes matching the expression. The nodes may not necessarily be in the same order that they appear in the document.
ORDERED_NODE_SNAPSHOT_TYPE 7 A result node-set containing snapshots of all the nodes matching the expression. The nodes in the result set are in the same order that they appear in the document.
ANY_UNORDERED_NODE_TYPE 8 A result node-set containing any single node that matches the expression. The node is not necessarily the first node in the document that matches the expression.
FIRST_ORDERED_NODE_TYPE 9 A result node-set containing the first node in the document that matches the expression.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support YesEdge ? Firefox Full support YesIE ? Opera Full support YesSafari ? WebView Android ? Chrome Android Full support YesEdge Mobile ? Firefox Android Full support YesOpera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes
invalidIteratorStateChrome Full support YesEdge ? Firefox Full support YesIE ? Opera Full support YesSafari ? WebView Android ? Chrome Android Full support YesEdge Mobile ? Firefox Android Full support YesOpera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes
iterateNextChrome Full support YesEdge ? Firefox Full support YesIE ? Opera Full support YesSafari ? WebView Android ? Chrome Android Full support YesEdge Mobile ? Firefox Android Full support YesOpera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes
resultTypeChrome Full support YesEdge ? Firefox Full support YesIE ? Opera Full support YesSafari ? WebView Android ? Chrome Android Full support YesEdge Mobile ? Firefox Android Full support YesOpera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes
snapshotItemChrome Full support YesEdge ? Firefox Full support YesIE ? Opera Full support YesSafari ? WebView Android ? Chrome Android Full support YesEdge Mobile ? Firefox Android Full support YesOpera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

See also

Document Tags and Contributors

المساهمون في هذه الصفحة: ExE-Boss, Sheppy, delete12345, fscholz, toluolubajo, trevorh, Martimus8, Brettz9
آخر مَن حدّثها: ExE-Boss,