XPath Tester

Evaluate XPath expressions against your XML.

//book/title
//book[@category='fiction']/title/text()
count(//book)
sum(//book/price)
//book[price > 10]/@id
//dc:creator

XPath Tester Online

The XPath tester lets you write an XPath expression and see instantly what it selects in your XML. Paste a document, type an expression, and the matching elements, attributes, text nodes, or computed value appear as you type — perfect for building selectors for XSLT, test automation, web scraping, or configuration files.

Try the examples

Load the sample bookstore catalog and click one of the example chips:

  • //book/title – every <title> of every book.
  • //book[@category='fiction']/title/text() – only the text of fiction titles, filtered by an attribute predicate.
  • count(//book) and sum(//book/price) – aggregate functions that return a number.
  • //book[price > 10]/@id – attributes of books matching a numeric condition.
  • //dc:creator – an element in a prefixed namespace.

XPath 1.0 quick reference

  • / selects from the root, // searches at any depth, . is the current node and .. its parent.
  • @name selects an attribute, * any element, text() text nodes, node() any node.
  • Predicates in square brackets filter: [1] (first), [last()], [@id='bk101'], [contains(title, 'XML')].
  • Axes reach further: ancestor::catalog, following-sibling::book, descendant-or-self::*.
  • Combine node-sets with | and conditions with and / or.

Namespaces

Namespaced documents are the number-one reason an XPath "doesn't work". The tester collects every xmlns:prefix declaration in the document and makes it available to your expressions. A default namespace has no prefix in the XML, so bind it to one in the prefix field and use it in the expression (//d:entry for an Atom feed).

Private and instant

Everything runs in your browser using its native XPath engine; the XML is never uploaded.

Use XPath inside stylesheets with the XSLT Transformer, explore a document as a tree in the XML Viewer, or work with JSON data in the JSONPath Tester.

Frequently Asked Questions

XPath 1.0, evaluated by your browser's built-in engine — the same version used by XSLT 1.0, most DOM APIs, Selenium, and many scraping libraries. XPath 2.0/3.1 functions such as matches() or string-join() are not available.

Prefixes declared in the document (xmlns:dc="…") are registered automatically, so //dc:creator just works. For a default namespace (xmlns="…" without a prefix), elements must be addressed with a prefix: use the default-namespace prefix field (d by default) and write //d:item.

A node-set is listed node by node with its type (element, attribute, text) and serialized value. Expressions such as count(), sum(), string(), or comparisons return a single number, string, or boolean instead.

The most common reasons are a default namespace on the root element, case differences (XPath is case-sensitive), and comparing text with extra whitespace — try normalize-space(title) = 'Midnight Rain'. Invalid syntax is reported as an error.