XPath Tester & Evaluator

Run XPath 1.0 expressions against your XML and see every matching node — live, in your browser.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

An XPath tester that evaluates XPath 1.0 expressions against your XML and shows every matching node — its location path, its type and its value — the moment you press Evaluate. It is built for developers who write scrapers, XSLT stylesheets, Selenium or Playwright selectors, or anyone who needs to confirm exactly what a query will pull out of an XML payload before wiring it into code. The document, the current expression and a short history of recent queries are all kept in your browser, so a refresh never loses your work.

How it works

The tool leans on the browser’s own standards-compliant engine rather than a re-implementation, so results match what your application will see. First the XML is run through DOMParser. If the parser produces a parsererror, the tester reports the message along with the line and column it can recover and marks the document Invalid; otherwise you get a Well-formed badge. Then the expression is handed to document.evaluate with the ANY_TYPE result mode. The engine decides whether your expression produced a node-set, a string, a number or a boolean, and the result type is shown so there is never any ambiguity.

For a node-set, every matched node is iterated and rendered in a table. Each row carries a generated location path (with positional predicates like book[2] when siblings share a tag name), a type label — element, attribute, text, comment, CDATA or processing instruction — and the node’s value. Elements that contain child elements are serialised back to XML so you can see their structure; leaf elements and attributes show their text. Scalar results are shown verbatim. Because the engine is XPath 1.0, the full 1.0 function library is available, including count(), contains(), starts-with(), normalize-space(), position() and last().

Everything is computed locally. Nothing is uploaded, which makes the tester safe for private configuration files and unreleased API responses.

Example

Load the sample library document and try these expressions:

  • //book[@available='true']/title selects the titles of in-stock books — three matches, each marked as an element.
  • //book/@category returns every category attribute — the rows are typed as attribute.
  • count(//book) returns the number 3.
  • //title[@lang='fr']/text() selects the French title’s text node.
  • //book[price > 20]/author uses a numeric predicate to find authors of pricier books.

Switch the predicate to @available='false' and the match count drops, so you can verify a selector behaves exactly as intended before committing it. Use Copy CSV or Download CSV to hand the matched paths and values to a teammate, or click any entry in Recent expressions to re-run an earlier query.

ExpressionResult typeMeaning
//book/titlenode-setevery title element
//book/@categorynode-setevery category attribute
count(//book)numberhow many books
//book[1]/author/text()node-setfirst author’s text
boolean(//book[@available='true'])booleanis anything in stock

Every figure and node is produced in your browser — your XML is never uploaded or stored on a server.

Ad placeholder (rectangle)