XPath Tester
Test XPath expressions against XML or HTML documents in your browser. See matche...Test XPath expressions against XML or HTML documents in your browser. See matched nodes, match counts and scalar values update live as you edit.
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.
XPath Tester Features
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
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.
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.
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.