Developer Tools · Validators
XPath tester and XML path finder.
Paste XML, type an XPath 1.0 expression and see what it selects as you type. Or click any element, attribute or text node in the tree to get its path.
Your XML and XPath
Document tree (click a node)
Paste XML to see its tree.
Result
Paste XML and type an expression.
What XPath is
XPath is a language for selecting parts of an XML document. An expression such as /catalog/book[2]/title is a path of steps from the root, and each step can carry a predicate in square brackets to filter nodes. XPath 1.0 expressions evaluate to one of four types: a node-set, a boolean, a number or a string. Node-sets are returned here in document order.
How to use this tool
Paste well-formed XML. The expression box evaluates as you type. Node-set results are listed with the absolute path of each match and highlighted in the tree. Scalar results such as count(//book) or sum(//price) show their value. Clicking a tree node fills the path box and the expression box with that node's path, so you can start from it and edit.
Worked example
Press Load example. The XML declares xmlns:b="urn:example:books" and holds two b:book elements priced 9.99 and 7.50. The expression //b:book[price < 8]/title returns one node, the title Le Petit Prince, with the path /catalog/*[local-name()='book' and namespace-uri()='urn:example:books'][2]/title. count(//b:book) returns the number 2. //book returns nothing, because the elements are in a namespace.
Rules that trip people up
- Positions start at 1.
//book[1]is the first book child of each parent;(//book)[1]is the first in the whole document. - Names are case-sensitive.
Titledoes not matchtitle. - No default namespace for unprefixed names. To match elements in an
xmlns="..."default namespace, use*[local-name()='name']instead. This tester maps only the prefixes the document declares withxmlns:prefix. //is shorthand for/descendant-or-self::node()/.- Version. Only XPath 1.0 functions work. Functions added in 2.0 or later return an error.
Limits
Evaluation uses your browser's own XPath engine, so edge-case behaviour and error wording can differ slightly between Chrome, Firefox and Safari. The tool needs well-formed XML (use the XML validator to find syntax errors) and does not check an XSD or DTD. Generated paths are absolute and position-based, so they break if the document structure changes; prefer an attribute-based expression such as //book[@id='b1'] for anything you keep. Adjacent text and CDATA are treated as one text() node, as XPath requires. The tree shows the first 1,500 nodes of a large document.
Frequently asked questions
Which XPath version does this tester use?
XPath 1.0, the version your browser implements natively through document.evaluate. XPath 2.0 and 3.x functions such as matches(), lower-case() or the for expression are not available and will return an error.
Why does my query return nothing when the XML has xmlns="..."?
In XPath 1.0 an unprefixed name in an expression never matches a namespaced element, and the default namespace is not applied to it. Either use a declared prefix (for example //b:book when the document declares xmlns:b) or match on local-name(), for example //*[local-name()='book'].
Why is the first item [1] and not [0]?
XPath positions start at 1. The expression //book[1] selects every book that is the first book child of its parent, while (//book)[1] selects only the first book in the whole document.
What does the click-to-get-path tree produce?
An absolute location path from the document root to the node you clicked. A [n] position is added only when same-named siblings exist. Namespaced elements are written with local-name() and namespace-uri() so the path works without any prefix setup.
Is my XML uploaded anywhere?
No. Parsing and evaluation run in your browser with DOMParser and document.evaluate. Nothing you paste is stored or sent.
Does this validate my XML against a schema?
No. It only needs the XML to be well-formed so it can be parsed. It does not check an XSD or DTD, and it does not run XSLT or XQuery.
Sources
W3C, XML Path Language (XPath) Version 1.0, Recommendation of 16 November 1999 (data model, location paths, node tests, predicates, core function library); MDN, Document.evaluate() and MDN, XPath. Links checked 2026-10-01. Everything runs in your browser. Nothing you paste is stored or sent.
Cite this page: TNAADO Tools. "XPath Tester and XML Path Finder (XPath 1.0)." https://tools.tnaado.ca/dev/validators/xpath-tester/. Accessed 2026-10-01.