XPath Tester.
Run XPath 1.0 expressions against XML and see the matching nodes, their paths and line numbers.
Runs in your browserAbout XPath Tester
XPath Tester evaluates an XPath 1.0 expression against an XML document and shows exactly what it selects. Paste the XML, type an expression such as //book[price > 20 and @year < 2010]/title, and you get each matching node with its type, name, string value, source line and an absolute location path, plus the matched XML itself. Expressions that return a number, string or boolean, such as count(//book) or sum(//price), show the computed value. The evaluator implements the whole XPath 1.0 recommendation: all thirteen axes, including following, preceding and namespace, abbreviated and full syntax, positional predicates that count backwards on reverse axes, unions, the comparison rules between node-sets, strings, numbers and booleans, and all 27 core functions from position() and last() to translate(), normalize-space() and lang(). The XML is parsed by a strict parser that reports well-formedness errors with a line and column, expands internal entities and resolves namespaces. The most common XPath surprise is the default namespace: in a document like an Atom feed or an SVG file, //entry finds nothing because unprefixed names only match elements in no namespace. Bind a prefix in the namespaces field, for example a=http://www.w3.org/2005/Atom, and write //a:entry, or use *[local-name()='entry']; the tool explains this when it detects the case. XPath 2.0 and 3.1 functions such as matches() or lower-case() are not available, and variables cannot be bound. id() uses id and xml:id attributes because there is no DTD validation. Everything runs in your browser.
How to Use
- Paste your XML document.
- Type an XPath 1.0 expression and, if needed, bind namespace prefixes.
- Review the matching nodes, their paths and the matched XML.
Frequently Asked Questions
Why does //item return nothing although the element is there?
The document probably has a default namespace (xmlns="..."). Bind a prefix to that URI in the namespaces field and write //p:item, or use //*[local-name()='item'].
Which XPath version is supported?
XPath 1.0, the version used by XSLT 1.0, browsers' document.evaluate, lxml and most scraping libraries. XPath 2.0+ functions are reported as unknown.
How does id() work without a DTD?
Attributes named id or xml:id are treated as IDs, since the document is not validated against a DTD.
Is my XML uploaded?
No. Parsing and evaluation run in your browser, and the page makes no network requests while you use it.
Related Tools
Format, minify, and validate XML.
View JSON as a tree with types and sizes, and get the JSONPath and JSON Pointer of every value.
Explain a regular expression token by token in plain English, or pick a tested pattern from the library.
Encode and decode HTML entities.
Escape and unescape strings for different formats.
Pretty print, minify, and validate JSON.