DevTools

XPath Tester

Test XPath expressions against XML or HTML live — see matched nodes, their location paths, and string/number/boolean results, all in your browser.

Prefer the terminal? See the CLI equivalent →
Loading tool…

About the XPath Tester

  • Live XPath evaluation
  • XML & HTML support
  • Syntax highlighting
  • Instant results
  • 100% private — runs in your browser
  • Free, no sign-up

XPath is a query language for selecting nodes in an XML or HTML document. You describe a path through the tree — elements, attributes, and text — optionally filtered by predicates, and XPath returns everything that matches. It is the backbone of XSLT, is widely used for web scraping and test automation (Selenium, Playwright), and is the most precise way to pinpoint content in a structured document.

This tester evaluates your expression against a document live and shows the results the way you actually need them: for a node-set it lists each matching node with its type, an absolute location path such as /bookstore/book[2]/title[1], and the serialized markup; for a function like count() or string() it shows the string, number, or boolean value. Toggle between XML and HTML parsing depending on your source.

Evaluation uses the browser’s native engine, which implements XPath 1.0 — the same version used by browser devtools, Selenium, and most tooling. Everything runs on your device, so the documents you test are never uploaded.

How to use it

  1. Paste your XML or HTML into the document editor, or load a file with the ⬆ upload button in its toolbar (a sample is provided to start).
  2. Choose whether to parse the source as XML (strict) or HTML (lenient) with the “Parse as” selector.
  3. Type an XPath expression — matches update live, with the count shown above the editor.
  4. Read the results: each matched node shows its location path and markup, and scalar expressions show their computed value. Copy any node or value with one click.

XPath syntax reference

The building blocks of an XPath 1.0 expression:

/
Selects from the root, or a direct child step (e.g. /bookstore/book).
//
Selects descendants anywhere below (e.g. //title finds every title).
@name
Selects an attribute (e.g. //book/@category).
. ..
The current node and the parent node.
*
A wildcard matching any element; @* matches any attribute.
[…]
A predicate that filters — [1] for position, [@lang="en"] or [price>30] for conditions.
text()
Selects text nodes; node() matches any node.
axes
Relationships like ancestor::, following-sibling::, descendant::.
functions
contains(), starts-with(), count(), string(), normalize-space(), local-name().
|
Union — combine two node-sets (e.g. //h1 | //h2).

Frequently asked questions

Which version of XPath does this support?+

XPath 1.0, via the browser’s built-in document.evaluate engine. That is the version implemented by web browsers, browser devtools, and most automation tools, so results here match what you will get in those environments. XPath 2.0/3.1 features (sequences, richer types, regex functions) are not available in the browser without a separate library.

What is the difference between the XML and HTML modes?+

XML mode parses strictly — tags must be well-formed and closed, and a syntax error is reported. HTML mode uses the lenient HTML parser, which tolerates unclosed tags and implied elements (like tbody), matching how a browser reads a page. Use HTML mode when testing selectors against real-world web pages.

How do I handle namespaces?+

Namespaced XML is the trickiest case in XPath 1.0. This tool builds a best-effort resolver from the document’s own namespace declarations, but prefixes in your expression must match. When a namespaced document will not match, the reliable workaround is to select by local name — for example //*[local-name()="title"] instead of //title.

What does the location path next to each match mean?+

It is an absolute, indexed XPath to that specific node, such as /bookstore/book[2]/title[1]. It tells you exactly where the match sits in the tree and is itself a valid expression you can copy and reuse to target that one node.

XPath or CSS selectors — which should I use?+

CSS selectors are shorter for common cases and are native to browsers, but XPath is more powerful: it can traverse upward to parents and ancestors, match on text content, and use functions and richer predicates. For deep or content-based queries — and for XML — XPath is usually the better fit.

Works well with

XPath Tester chains with these tools — send your result straight on:

Related tools