files/en-us/web/api/xpathresult/stringvalue/index.md
{{APIRef("DOM")}} {{AvailableInWorkers}}
The read-only stringValue property of the
{{domxref("XPathResult")}} interface returns the string value of a result with
{{domxref("XPathResult.resultType")}} being STRING_TYPE.
The return value is the string value of the XPathResult returned by
{{domxref("Document.evaluate()")}}.
In case {{domxref("XPathResult.resultType")}} is not STRING_TYPE, a
{{domxref("DOMException")}} of type TYPE_ERR is thrown.
The following example shows the use of the stringValue property.
<div>XPath example</div>
<div>Text content of the <div> above: <output></output></div>
const xpath = "//div/text()";
const result = document.evaluate(
xpath,
document,
null,
XPathResult.STRING_TYPE,
null,
);
document.querySelector("output").textContent = result.stringValue;
{{EmbedLiveSample('Examples', 400, 70)}}
{{Specifications}}
{{Compat}}