XPath Tester

Type an XPath expression and see the matching nodes from your XML immediately, with the count in the status.

XML
Matches
Runs locally in your browser

About the XPath Tester

XPath is how you address parts of an XML document in XSLT, Selenium locators, Scrapy selectors, SOAP tooling and configuration files. Getting an expression right usually takes a few attempts, and this tester makes each attempt instant: paste the document, type the expression in the toolbar, and the matches appear as serialised XML, attribute values or text depending on what the expression selects.

The evaluator is the browser's built-in XPath 1.0 engine, so it supports the full 1.0 syntax: axes such as ancestor:: and following-sibling::, predicates with positions and attribute tests, and functions such as contains(), count(), normalize-space() and sum(). Expressions that return a number, string or boolean show that value instead of a node list.

XPath 2.0 and 3.1 features, for example for expressions, regular-expression functions and sequences, are not available in browsers. Namespaced documents need the local-name workaround, //*[local-name()="title"], because prefixes cannot be registered here. For JSON, the equivalent tool is the JSONPath Tester.

How to use

  1. Paste XML on the left, or use the sample.
  2. Type an XPath expression in the toolbar. Results update as you type.
  3. Read the match count in the status; copy the results if needed.

Common questions

Why does //title return nothing on my namespaced document?
Elements in a default namespace are not matched by unprefixed names in XPath 1.0. Use //*[local-name()="title"].
Can I get attribute values only?
Yes. An expression ending in /@id returns each attribute as name="value".
Is XPath 3 supported?
No. Browsers implement XPath 1.0. Most Selenium and XSLT 1.0 expressions are covered.
How do I count matches?
The status shows the count, or use count(//book) to get it as a value.