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
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat 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
Paste XML into the left panel.
Type an XPath expression in the expression field.
Results update live as you type.
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.
//book[@genre='fiction']/titleTwo 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.
Related Tools
XML Beautifier
Format and prettify minified or messy XML with configurable indentation. Also minify XML to remove whitespace.
JSON Path Tester
Test JSONPath expressions against your JSON.
XML to JSON Converter
Parse and convert XML to clean JSON instantly — attributes, namespaces, and nested elements handled.
JSON Formatter
Format, validate, and beautify JSON instantly — with clear error messages, Tree View, Diff mode, and Schema validation.
JSON Validator
Validate JSON syntax online. Shows valid/invalid status, error location (line and column), and structure stats including type, key count, and depth.
HTML to XML Converter
Convert HTML to well-formed XML. Closes void elements, lowercases tags, escapes attributes, and adds an optional XML declaration.

