XPathResult: snapshotLength-Eigenschaft

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Hinweis: Diese Funktion ist in Web Workers verfügbar.

Die schreibgeschützte snapshotLength-Eigenschaft der XPathResult-Schnittstelle stellt die Anzahl der Knoten im Ergebnissnapshot dar.

Wert

Ein Integer-Wert, der die Anzahl der Knoten im Ergebnissnapshot darstellt.

Ausnahmen

TYPE_ERR

Falls XPathResult.resultType nicht UNORDERED_NODE_SNAPSHOT_TYPE oder ORDERED_NODE_SNAPSHOT_TYPE ist, wird eine XPathException vom Typ TYPE_ERR ausgelöst.

Beispiele

Das folgende Beispiel zeigt die Verwendung der snapshotLength-Eigenschaft.

HTML

html
<div>XPath example</div>
<div>Number of matched nodes: <output></output></div>

JavaScript

js
const xpath = "//div";
const result = document.evaluate(
  xpath,
  document,
  null,
  XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
  null,
);
document.querySelector("output").textContent = result.snapshotLength;

Ergebnis

Spezifikationen

Specification
DOM
# dom-xpathresult-snapshotlength

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
snapshotLength

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support