XPath Tester

Test XPath expressions against XML or HTML documents in your browser. See matche...

SecureFastFree

Updated

Results update live as you type. Supports XPath 1.0: axes, predicates, and functions like count(), string(), contains() and text().

Enter a document and an expression to see matches here.

Example XPath expressions

Quick answer

To test an XPath expression, paste an XML or HTML document into this tester and type your expression, for example //book/title. It evaluates the expression in your browser with the native document.evaluate engine and shows the result live: a node set lists every matched node with a count, while an expression like count(//book) or string(//title) shows its scalar value. Everything runs client side on XPath 1.0, so your document is never uploaded.

SSL Secured
256-bit Encryption
Cloud Processing
Mobile Friendly

XPath Tester Features

Live Results - Evaluates as you type, no submit needed
All Result Types - Node sets, strings, numbers and booleans
XML And HTML - Strict XML or lenient HTML parsing
Match Count - Total matches plus per node details
Copy Output - Copy matched markup or the scalar value
Client Side - Runs in your browser, nothing uploaded

Why Use XPath Tester?

Live Evaluation

Matches update the moment you edit the document or the expression. No submit button, no round trip to a server.

Every Result Type

Detects whether your expression returns a node set, a string, a number or a boolean and renders each one correctly.

Friendly Errors

A malformed expression or broken XML shows a plain message instead of crashing, so you can fix the syntax fast.

Runs In Your Browser

Parsing and evaluation use the browser DOMParser and document.evaluate. Your document never leaves your device.

Common Uses for the XPath Tester

Web Scraping Selectors

Draft and verify XPath selectors for Scrapy, Selenium, Puppeteer or Playwright before wiring them into code.

XSLT And Config Debugging

Test the match and select patterns used in XSLT stylesheets and XML config files interactively.

XML Data Extraction

Pull exactly the nodes or values you need from API responses, feeds and exports.

Learning XPath

Experiment with axes, predicates and functions against the sample document and watch results change live.

How It Works

1

Paste your document

Drop an XML document into the left pane, or switch to HTML mode to query a page you scraped. Load the sample to see a working example.

2

Write an XPath expression

Type an expression such as //book/title, //item[@id='2'] or count(//book). The expression box accepts any XPath 1.0 syntax.

3

Read the results

Node sets list each match with its type, name and serialized markup plus a match count. String, number and boolean expressions show the scalar value. Copy any result with one click.

XPath Testing Tips

Build It Up Step By Step

Start with //book, confirm it matches, then add a predicate like //book[@category='fiction'] and finally a path like /title. Testing each layer makes a wrong step obvious.

Sidestep Namespaces With local-name()

If a document uses a default namespace, //book returns nothing. Use //*[local-name()='book'] to match by name regardless of namespace.

Mind Case And Slashes

XML names are case sensitive and / only steps one level. Use // to search at any depth and copy tag names exactly to avoid empty results.

Frequently Asked Questions

Paste an XML or HTML document into the document pane, then type your XPath expression in the box above it. This tester evaluates the expression against the document in your browser and shows the result live: a node set lists every matched node with a count, while an expression like count() or string() shows its scalar value. Nothing is uploaded, so it works on private data and offline.
XPath 1.0 has four result types: node sets (the nodes selected by a path such as //book), strings (from string() or an attribute value), numbers (from count(), sum() or number()), and booleans (from a comparison or the boolean() function). This tester uses ANY_TYPE so the engine reports the natural type, then renders a list of nodes or the single scalar value accordingly.
Yes. Switch the toggle to HTML and the document is parsed with the lenient HTML parser, which is what browsers and scraping tools use. XML mode uses strict parsing and reports a parse error for malformed markup, while HTML mode tolerates unclosed tags. Use HTML mode to test selectors for Selenium, Puppeteer or Playwright.
The usual causes are case sensitivity (XML element and attribute names are case sensitive), using / where you needed // to search at any depth, a predicate that filters everything out, or a namespace on the elements. Check the exact tag name and try a broader path like //*[local-name()='book'] to rule out namespace issues.
It builds a namespace resolver from the document root, so expressions that use a prefix declared in the document work. XPath 1.0 has no default namespace, meaning a bare //book will not match elements in a default (prefix-less) namespace even though they look unprefixed. The reliable workaround is a local-name() test, for example //*[local-name()='book'].
This tester uses the browser's XPath 1.0 engine, so common functions all work: count(), sum(), position(), last(), contains(), starts-with(), string(), string-length(), normalize-space(), concat(), substring(), translate() and the boolean not(). XPath 2.0 and 3.1 additions are not part of the browser engine and are not supported.
Use @ to select an attribute, so //book/@category returns the category attribute of every book. Use text() to select text nodes, so //title/text() returns the text inside each title. To get a single string value rather than nodes, wrap the path in string(), for example string(//book[1]/author).
Yes. The document and the expression are parsed and evaluated entirely in your browser with the built-in DOMParser and document.evaluate. No document text is sent to a server, logged or stored, which is why the tool keeps working with your network disconnected.

Related Tools