<div>XPath example</div>
<p>Text is 'XPath example': <output></output></p>XPathResult: booleanValue property / notebook
XPathResult: booleanValue property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const xpath = "//div/text() = 'XPath example'";
const result = document.evaluate(
xpath,
document,
null,
XPathResult.BOOLEAN_TYPE,
null,
);
document.querySelector("output").textContent = result.booleanValue;