DataToolsLab
XML Tools

XPath Tester

Evaluate an XPath 1.0 expression against XML and see every matching node, with the value that selects it.

Loading tool…

What is XPath Tester?

An XPath 1.0 evaluator working on the parsed document. It returns nodes — elements, attributes, text, comments, processing instructions — with their paths, so you can build the expression you need and confirm it before it goes into a stylesheet or a query.

How it works

The expression is tokenised and parsed into steps with axes, node tests and predicates, then evaluated against the tree. All twelve XPath 1.0 steps are supported — child, descendant, descendant-or-self, parent, ancestor, ancestor-or-self, following-sibling, preceding-sibling, following, preceding, attribute and self — along with attribute, text, comment and processing-instruction tests, position predicates, `and`/`or`, comparisons and the common node-set, string and number functions. The reverse axes count position() from the context node, so `ancestor::*[1]` is the parent and `preceding-sibling::*[1]` the sibling just before, while every result set is still listed in document order. What is not supported is reported as such: the tool names the axis or function instead of quietly returning nothing.

  1. Paste the document. Drop in XML, a schema, a feed or an XPath expression. Everything is parsed in the page: no upload, no server round trip, and the tools keep working with the network switched off.
  2. Set the options that match your document. Indent unit, whether to keep comments, which dialect, which output method. The defaults are the safe ones — nothing that changes meaning is enabled for you.
  3. Read the result, then copy or download it. Results appear as you type, copy straight to the clipboard, and download with a sensible filename (.xml, .xsd, .csv). Reset returns every field to its default.

Examples

A minified document from an API response

Paste one line of XML and the Formatter indents it, wraps long start tags one attribute per line and normalises empty elements — without touching text inside mixed content.

An XPath that works in Chrome and not in your servlet

The XPath Tester evaluates against a real tree and reports the axis or function it cannot support, instead of returning zero nodes and letting you guess why.

A document that will not parse

The Validator gives line and column for every mismatched tag, stray ampersand and duplicate attribute, with the reason in words: which open element was expected, which was found.

A schema that only half matches your data

The XSD Validator marks each violation with the path of the offending node, and the Schema Generator goes the other way — inferring a starting-point XSD from real documents.

Common mistakes

Assuming a pretty-printer cannot change meaning

Whitespace between elements is often insignificant, but inside mixed content it is not: `<p>Hello <b>world</b></p>` must stay on one line. Formatting here re-indents element-only content and leaves mixed content alone.

Treating a validation pass as proof of interoperability

The DTD and XSD validators implement honest subsets. A document reported valid here can still be rejected by a full validator that understands identity constraints, substitution groups or XSD 1.1 assertions — each page lists what it does not cover.

Reading the whole document because the parser did

A DOCTYPE is not inert. If your parser resolves external entities, pasting an untrusted document is enough to read a file or call an internal URL. The XXE Risk Checker shows what a document asks for; the fix is in the parser configuration.

Forgetting that attributes and elements are not interchangeable

`<id>1</id>` and `id="1"` mean different things to every schema and every XPath. When converting to CSV or YAML the distinction is preserved (`@id`), because flattening it away is the change that costs an afternoon later.

Frequently asked questions

Why does my expression return nothing in the browser but work in XSLT?

Namespaces are the usual reason: in XPath 1.0 an unprefixed name means no namespace, so `/feed/entry` matches nothing in an Atom document whose elements are in the Atom namespace. Declare a prefix and use `/atom:feed/atom:entry`.

Which parts of XPath 1.0 are not implemented?

Entity-reference node tests, the namespace axis with wildcard namespace tests, and a handful of string functions with locale-sensitive behaviour. XPath 2.0 constructs — `for`, `if`, sequence types, `//`-style quantified expressions — are a different language and are reported as unsupported.

Can I use the result to build a query?

Yes, that is the point: the generated paths are in the same syntax XSLT and most XML databases accept. Copy a match path into a stylesheet's select attribute and it behaves identically, because the tester evaluates the expression the same way a template match does.

Online