XPathResult: stringValue 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 stringValue Eigenschaft der XPathResult Schnittstelle gibt den Zeichenfolgenwert eines Ergebnisses zurück, wenn XPathResult.resultType STRING_TYPE ist.

Wert

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

Ausnahmen

TYPE_ERR

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

Beispiele

Das folgende Beispiel zeigt die Verwendung der stringValue Eigenschaft.

HTML

html
<div>XPath example</div>
<div>Text content of the &lt;div&gt; above: <output></output></div>

JavaScript

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

Ergebnis

Spezifikationen

Specification
DOM
# dom-xpathresult-stringvalue

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
stringValue

Legend

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

Full support
Full support