XPathResult: booleanValue-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 booleanValue-Eigenschaft des XPathResult-Interfaces gibt den booleschen Wert eines Ergebnisses zurück, wobei XPathResult.resultType BOOLEAN_TYPE ist.

Wert

Der Rückgabewert ist der boolesche Wert des XPathResult, das von Document.evaluate() zurückgegeben wird.

Ausnahmen

TYPE_ERR

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

Beispiele

Das folgende Beispiel zeigt die Verwendung der booleanValue-Eigenschaft.

HTML

html
<div>XPath example</div>
<p>Text is 'XPath example': <output></output></p>

JavaScript

js
const xpath = "//div/text() = 'XPath example'";
const result = document.evaluate(
  xpath,
  document,
  null,
  XPathResult.BOOLEAN_TYPE,
  null,
);
document.querySelector("output").textContent = result.booleanValue;

Ergebnis

Spezifikationen

Specification
DOM
# dom-xpathresult-booleanvalue

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
booleanValue

Legend

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

Full support
Full support