← 返回首页
XPathResult: stringValue プロパティ - Web API | MDN

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

XPathResult: stringValue プロパティ

Baseline Widely available

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

stringValueXPathResult インターフェイスの読み取り専用プロパティで、 XPathResult.resultType が STRING_TYPE である結果の文字列値を返します。

メモ: この機能はウェブワーカー内で利用可能です。

In this article

返値は Document.evaluate() が返す XPathResult の文字列値です。

例外

TYPE_ERR

XPathResult.resultType が STRING_TYPE でない場合、 TYPE_ERR 型の XPathException が発生します。

次の例では stringValue プロパティを使用しています。

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;

結果

仕様書

Specification
DOM
# dom-xpathresult-stringvalue

ブラウザーの互換性

Enable JavaScript to view this browser compatibility table.