XPath Tester

Test XPath expressions on XML.

0 nodes

About the XPath Tester

Type an XPath expression and see the nodes it selects, updating on every keystroke against the XML in the panel beside it. Element matches appear as their full markup, text and attribute matches as their values, and a node count sits next to the expression box. Malformed XML or an invalid expression is reported inline rather than silently returning nothing.

How to use the XPath Tester

  1. Paste your XML into the XML panel, replacing the sample document.
  2. Type an XPath expression into the box at the top; results update as you type.
  3. Read the matches in the Results panel and the node count beside the expression.
  4. Press Copy to take the matched nodes with you.

Frequently asked questions

Which version of XPath does this support?
XPath 1.0. It evaluates with the browser's built-in document.evaluate, and the DOM XPath specification requires a conforming implementation of XPath 1.0, so XPath 2.0 and 3.1 additions such as matches() are not available.
Why does //book match nothing when the XML looks right?
Usually a default namespace. XPath treats an unprefixed name as being in no namespace, so if your root declares xmlns="...", a plain //book matches nothing. Match on the local name instead: //*[local-name()='book'].
How do I select an attribute rather than an element?
Use the attribute axis with @, as in //book/@id. Attribute matches are listed by value, one per line, while element matches are shown as their full markup.
What does an expression like count(//book) return?
A single value rather than a node list. Expressions producing a number, a string, or a boolean show that one result on its own line, and the node count reads 1.
Is my XML uploaded?
No. Parsing and evaluation both use your browser's own XML and XPath engines, so a document full of internal data never leaves the page.

Related tools