<div>XPath example</div>
<div>Is XPath result a node set: <output></output></div>XPathResult: resultType property / notebook
XPathResult: resultType 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";
const result = document.evaluate(
xpath,
document,
null,
XPathResult.ANY_TYPE,
null,
);
document.querySelector("output").textContent =
result.resultType >= XPathResult.UNORDERED_NODE_ITERATOR_TYPE &&
result.resultType <= XPathResult.FIRST_ORDERED_NODE_TYPE;