Test XPath expressions against your XML documents online. Evaluate real XPath queries and inspect the matching elements, attributes and text nodes instantly.
Results will appear here
Enter XML and an XPath expression, then press Evaluate XPath
Load sample data to get started
What this tool can do
Real XPath 1.0 Evaluation
A hand-written engine parses and evaluates the expression - never pattern matching
Elements, Attributes & Text
Match elements, @attributes, text() nodes and comments, each shown as its own kind
Predicates & Comparisons
[@id='1'], [price>10], [2], [last()] with = != < <= > >= and and / or
Common Functions
count, string, sum, contains, starts-with, position, last, not, substring and more
Ten Axes
child, descendant, parent, ancestor, self, attribute, sibling axes and the // shortcut
Separate Error Reporting
XML parse errors and expression errors are reported apart, each with its position
Evaluates As You Type
The results refresh while you edit, and Evaluate XPath or Ctrl+Enter forces a run
Copy Results
One click puts every match and its location path on your clipboard
Methodology and approach
The tester parses the document with a real XML parser and evaluates the expression with a hand-written XPath 1.0 engine: location paths, the child, descendant, parent, ancestor, attribute, self and sibling axes, name tests, text() and node() node tests, predicates with comparisons and and / or, and the common functions such as count, contains, position and last are evaluated for real. XML errors and expression errors are reported separately, each with its position.
XPath is a query language for XML: an expression names the parts of a document you want - elements, attributes or text - and the engine returns every node the expression selects. //book finds every book element anywhere in the document, //book/title narrows that to the title inside each one, and a predicate such as //book[@id='1'] keeps only the books whose id attribute has that value.
An XPath tester runs those expressions against a real document before you put them into an application, a style sheet or a data pipeline. Calzyra's tester parses the XML with a real XML parser and evaluates the expression with a hand-written XPath 1.0 engine: nothing is approximated with pattern matching, and the matches you see are the nodes the expression actually selected.
Paste your XML into the panel on the left - a sample document is already loaded so the workspace demonstrates the workflow immediately. Type the expression into the XPath Expression field above the editors; the results refresh automatically as you type, and the Evaluate XPath button (or Ctrl+Enter, or Enter inside the field) runs it on demand.
Each match is listed with its kind - element, attribute, text or comment - the location path that leads to it, and its serialized form. A scalar expression such as count(//book) returns the value rather than a node-set, and the number of matches is reported above the list. Everything runs in your browser; nothing is uploaded.
Errors are kept apart on purpose. A document that does not parse reports the parser's error with its line and column; an expression the engine cannot parse reports the column where it stopped; a valid expression that selected nothing says so explicitly. The previous matches are cleared the moment a run fails, so a stale result is never left next to an expression it does not belong to.
These four expressions are the everyday vocabulary of XPath. With the sample document the tool opens with: //book selects the three book elements, //book/title selects their three title elements, //book[@id='1'] selects the single book whose id attribute equals 1, and //book/title/text() selects the three text nodes inside the titles - the text itself rather than the element around it.
A numeric predicate is a position test: //book[2] is the second book, and [last()] is the final one. Comparisons such as //book[price>25] filter on a child's value, and functions such as contains(), starts-with(), not() and count() compose inside predicates or wrap the whole expression. The results below were produced by the same engine the tool runs.
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<book id="1" available="true">
<title>XML in Practice</title>
<author>Maya Chen</author>
<price>29.99</price>
</book>
<book id="2" available="false">
<title>Learning XML</title>
<author>Erik T. Ray</author>
<price>39.95</price>
</book>
<book id="3" available="true">
<title>XPath Essentials</title>
<author>Sam Rivera</author>
<price>24.50</price>
</book>
</catalog>//book[@id='1']
1 match
1. <book id="1" available="true">
<title>XML in Practice</title>
<author>Maya Chen</author>
<price>29.99</price>
</book> /catalog/book[1]An XPath expression that is almost right usually fails silently in production: it selects nothing, or it selects the wrong branch of a nearly-symmetric document. Testing it against the real document first shows exactly which nodes it reaches, through which paths, so the mistake is visible in seconds rather than in a log file later.
The tester also doubles as an inspection tool. An expression such as //@sku lists every attribute with that name wherever it appears, and //book/title/text() pulls the values out of a repeating structure without writing any code - useful when you are exploring an unfamiliar XML export, checking an API response, or preparing a query for a larger pipeline.
Common questions about this tool