Firefox Tomorrow

web api instance property

XPathResult: numberValue property

View on MDN ↗

Available in workers

The read-only numberValue property of the XPathResult interface returns the numeric value of a result with resultType being NUMBER_TYPE.

Value

The return value is the numeric value of the XPathResult returned by evaluate().

Exceptions

TYPE_ERR

In case resultType is not NUMBER_TYPE, a DOMException of type TYPE_ERR is thrown.

Examples

The following example shows the use of the numberValue property.

HTML

<div>XPath example</div>
<div>Number of &lt;div&gt;s: <output></output></div>

JavaScript

const xpath = "count(//div)";
const result = document.evaluate(
  xpath,
  document,
  null,
  XPathResult.NUMBER_TYPE,
  null,
);
document.querySelector("output").textContent = result.numberValue;

Result

Interactive exampleOpen the canonical MDN source to run this embedded demo.

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.