WebToolsPlanet
Converter Tools

XPath Tester

Paste XML, type an XPath expression, and see every matching node — with its type, name, value, and full serialized form — updating live as you edit.

Last updated: May 27, 2026

Client-Side Processing
Input Data Stays on Device
Instant Local Execution

Find this tool useful? Support the project to keep it free!

Buy me a coffee

What is XPath Tester?

XPath is a query language for selecting nodes from an XML document. It is the SQL of XML — a small but expressive syntax that lets you reach into any depth of nesting, filter by attribute, and aggregate values. It is also used by XSLT, libxml2, and many scrapers (lxml, Scrapy) to address parts of HTML/XML documents.

This tester evaluates XPath 1.0 expressions using the browser's built-in `document.evaluate` and `DOMParser`. Type a path like `//book[@genre='fiction']/title` and you see every matching node — element, attribute, text, comment, or CDATA — each shown with its name, value, and serialized form. Scalar XPath results (e.g. `count(//book)`, `name(//book[1])`) appear as a single value with the result type indicated.

How to Use XPath Tester

1

Paste XML into the left panel.

2

Type an XPath expression in the expression field.

3

Results update live as you type.

4

Each match shows the node type, name, value, and serialized XML.

Common Use Cases

  • Validating an XPath before using it in a scraper or XSLT transform.
  • Finding the right XPath for a specific element in a large XML document.
  • Testing attribute selectors and predicates (e.g. //a[@href and not(@target)]).
  • Debugging why an XPath returns nothing — see XML parse errors and XPath errors inline.
  • Learning XPath syntax through interactive feedback.

Example Input and Output

An XPath with attribute filter selects matching elements.

XPath expression
//book[@genre='fiction']/title
Matched nodes
Two matches: <title>The Great Gatsby</title> and <title>1984</title>

Privacy

All XML parsing and XPath evaluation happen in your browser. No content is sent to a server.

Namespaces

Document-default namespaces (xmlns="...") require a namespace-resolver in XPath 1.0. As a workaround, use //*[local-name()="elementname"] to match elements ignoring the namespace.

Frequently Asked Questions

Which XPath version is supported?
Browsers ship XPath 1.0 (via document.evaluate). XPath 2.0/3.0 features (sequences, advanced functions, regex) are not supported — they require a server-side processor.
Can I test XPath on HTML?
Yes, if you wrap your HTML in valid XML (well-formed). HTML5 parsers are forgiving — XPath requires strict XML. For HTML scraping, save the page as XHTML or convert with html-to-xml first.
Why does my XPath return nothing?
Common causes: the XML uses default namespaces (XPath 1.0 in browsers does not handle them transparently — use local-name() or pre-strip namespaces); a typo in element/attribute name; predicate filter is too strict.
Does this send my XML anywhere?
No. All parsing and XPath evaluation happen locally in your browser using the built-in DOMParser and document.evaluate.