Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. XPathResult
  4. stringValue

XPathResult: stringValue property

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⁩.

Note: This feature is available inWeb Workers.

The read-onlystringValue property of theXPathResult interface returns the string value of a result withXPathResult.resultType beingSTRING_TYPE.

Value

The return value is the string value of theXPathResult returned byDocument.evaluate().

Exceptions

TYPE_ERR

In caseXPathResult.resultType is notSTRING_TYPE, aDOMException of typeTYPE_ERR is thrown.

Examples

The following example shows the use of thestringValue property.

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;

Result

Specifications

Specification
DOM
# dom-xpathresult-stringvalue

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp