只读
stringValue
特性为
XPathResult
interface returns the string value of a result with
XPathResult.resultType
being
STRING_TYPE
.
var value = result.stringValue;
The return value is the string value of the
XPathResult
返回通过
Document.evaluate()
.
若
XPathResult.resultType
不是
STRING_TYPE
,
XPathException
类型
TYPE_ERR
is thrown.
The following example shows the use of the
stringValue
特性。
<div>XPath example</div> <div>Text content of the <div> above: <output></output></div>
var xpath = "//div/text()";
var result = document.evaluate(xpath, document, null, XPathResult.STRING_TYPE, null);
document.querySelector("output").textContent = result.stringValue;
| 规范 | 状态 | 注释 |
|---|---|---|
|
DOM (文档对象模型) 3 级 XPath 规范
The definition of 'XPathResult.stringValue' in that specification. |
推荐 | 初始定义 |
No compatibility data found. Please contribute data for "api.XPathResult.stringValue" (depth: 1) to the MDN 兼容性数据存储库 .