Last updated on

XPath in JS


I was looking for a solution to use xpath in js when i learned about a built-in solution. The js usage and the typescript interface are shown below.

document.evaluate(expression, contextNode, resolver, type, result);
interface XPathEvaluatorBase {
  evaluate(
    expression: string,
    contextNode: Node,
    resolver?: XPathNSResolver | null,
    type?: number,
    result?: XPathResult | null,
  ): XPathResult;
}

The result is an editor to compile xml and xpath queries. And on top there are some exercises to study xpath.