XPath Tester
This XPath tester lets you write an expression and see the matches immediately. XPath selects parts of a document by path, position, attribute or predicate: a double slash searches at any depth, @ selects an attribute, [n] picks by position, and a predicate filters by value. It runs the browser own XPath 1.0 engine — the same one behind document.evaluate — so what you see is exactly what your code will see rather than a reimplementation that might differ in the corners. Namespaces are resolved against the document itself, so namespaced files work without you having to declare prefixes separately.
How it works
XPath selects parts of a document by path, position, attribute or predicate. // searches at any depth, @ selects an attribute, [n] picks by position and [predicate] filters by value.
This runs the browser's own XPath 1.0 engine — the same one behind document.evaluate — so results match what your code will see rather than a reimplementation that might differ.
Everything runs in your browser — nothing you paste is sent to a server.
The syntax, briefly
| Expression | Meaning |
|---|---|
/catalog/book | book elements directly under catalog |
//book | book elements anywhere |
//book[1] | The first book in each parent |
//book/@id | The id attribute of every book |
//book[@category='fiction'] | Books with that attribute value |
//book[price>10]/title | Titles of books over 10 |
count(//book) | How many books there are |
//book[last()] | The last book |
Positions start at 1
XPath indexes from 1, not 0. //book[1] is the first book. This trips up nearly everyone coming from a
programming language, and produces an off-by-one that looks like missing data.
Functions as well as paths
An expression does not have to return nodes. count(), string(), sum() and
boolean() return values, and the tool reports which kind of result came back.
Frequently asked questions
How do I test an XPath expression?
Paste your XML, then type an expression such as //book/title. The matches appear as you type.
Which XPath version is this?
XPath 1.0, which is what browsers implement. Versions 2.0 and 3.1 exist but need a separate engine — most tools and libraries still use 1.0.
Does it handle namespaces?
Yes. Prefixes are resolved against the document root, so a namespaced document works without declaring them separately.
Can I see the matched elements as markup?
Yes. By default the text content is shown; tick the markup option to see each matched element serialised in full.
What if my expression matches nothing?
You get a note saying the expression is valid but matched nothing, which distinguishes a wrong expression from a wrong assumption about the document.
Is my XML uploaded?
No. The evaluation runs entirely in your browser.
Related tools
JSONPath Tester
This JSONPath tester runs an expression against your JSON and shows every match live.
XML Viewer
This XML viewer renders any document as a collapsible tree with attributes and copyable paths.
XSLT Transformer
This XSLT transformer runs a 1.0 stylesheet against your XML in the browser.