XPath Tester

Run an XPath 1.0 expression against XML and see the matching nodes, or the string, number or boolean result. Evaluation uses the XPath engine built into your browser.

Use the tool

Why this tool exists

XPath is how you pick elements out of XML in XSLT, test tools, scrapers and many configuration systems. Writing an expression blind and running the whole pipeline to see if it works is slow. A tester gives you an answer in a moment.

Put your XML in one box and the expression in the other. Node results are listed with numbers, attributes show as name and value, and text nodes show their text. Expressions that return a count, a string or a true or false are labelled with their type. Because the browser engine implements XPath 1.0, features from later versions are not available, which is worth remembering if your target uses XPath 2 or 3. Nothing is uploaded.

How to use it

  1. Paste your XML into the first box.
  2. Enter an XPath expression such as //book[@year > 1900]/title/text() in the second box.
  3. Read the results: a node count with each match, or a typed value.
  4. Adjust the expression until it selects what you need.

Frequently asked questions

Which XPath version is supported?

XPath 1.0, as implemented by your browser. Functions and syntax that were added in XPath 2.0 and 3.0, such as regular expression functions, are not available.

How are results shown?

Elements are serialised as XML, attributes as name="value" and text nodes as their text. Counts, strings and booleans are shown with a label such as number: 3.

Why do I get 0 nodes when I expect a match?

Common causes are XML namespaces, since a default namespace needs prefix handling in XPath 1.0, a leading slash that anchors at the wrong place, or comparing text with extra whitespace.

What if my XML is invalid?

The tool reports that the XML is not well-formed, with the parser message. An invalid expression gives an XPath error instead.