XPath Evaluator
Paste XML and test XPath expressions with live results and node highlighting
Paste any XML, type an XPath expression, and see matched nodes highlighted instantly — with counts, types, and values shown in a side panel. Preset queries are included for common patterns so you don't have to memorize syntax. And everything runs in your browser. Nothing gets uploaded.
How It Works
The browser's built-in document.evaluate() API parses your XML into a DOM tree, then runs your XPath expression against it. Matched nodes get pulled out with their types (element, attribute, text, etc.) and displayed in a results panel. The original XML is syntax-highlighted with matches marked so you can visually confirm what got selected. No regex hacking, no string splitting — just the W3C XPath 1.0 engine that ships with every modern browser.
Examples
Extracting book titles from a catalog
You have a bookstore XML feed and need just the title text from each book entry.
//book/title/text()
Text: "Harry Potter"
Text: "Learning XML"
Text: "The Great Gatsby"
(3 matches)
Filtering products by attribute value
An e-commerce XML export with hundreds of items. You only want products where the category attribute equals "electronics".
//product[@category='electronics']
Element: <product category="electronics">
<name>Wireless Mouse</name>
<price>29.99</price>
</product>
(1 match)
Grabbing the third item in a list
Your SOAP response has a repeating element and you need just one specific entry by position.
(//item)[3]
Element: <item id="c3">
<desc>Premium Widget</desc>
</item>
(1 match)
Who Uses This
Testing XPath queries before embedding them in code that parses SOAP responses or XML configs.
Verifying that XML test data contains the right structure and values before running automated checks.
Learning XPath syntax by experimenting with expressions and seeing results in real time.
Pulling specific fields out of large XML exports from legacy systems or government data feeds.
Common Mistakes
Searching for //Book when the actual element is <book> returns zero results. XML tag names are case-sensitive, so your XPath has to match exactly.
Double slash (//) searches the entire document tree. Single slash (/) only looks at direct children. If you write //title you might match titles nested three levels deep that you didn't want. Be specific when the structure is known.
If your XML uses namespaces (like xmlns:ns="..."), a plain //element won't match <ns:element>. Browser XPath 1.0 doesn't support default namespace resolution well — you may need to use //*[local-name()='element'] as a workaround.
A single unclosed tag or mismatched quote breaks the entire parse. The tool will tell you the XML is invalid, but the error message points to where the parser gave up — not always where the actual mistake is. Fix your XML first, then query it.
Technical Details
- Processing: 100% client-side — XML never leaves your browser
- XPath Version: 1.0 (browser-native via
document.evaluate()) - Browser Support: Chrome, Firefox, Safari, Edge
- Max XML Size: Limited only by available browser memory
- Result Types: Elements, attributes, text nodes, numbers, booleans
Frequently Asked Questions
What is XPath used for?
XPath is a query language for selecting nodes from XML documents. Think of it like SQL for XML — you write an expression that describes which parts of the document you want, and the engine returns matching nodes. It's used heavily in XSLT transformations, web scraping, and automated testing with tools like Selenium.
What is the difference between XPath and CSS selectors?
CSS selectors work great for HTML and move forward through the document tree. XPath can do the same thing but also move backward — selecting parent nodes, siblings, or ancestors. XPath also handles XML (not just HTML) and supports functions like contains(), count(), and math operations that CSS selectors can't touch.
Can I test XPath 2.0 or 3.0 expressions here?
No. Browsers only support XPath 1.0 natively, and this tool uses the browser's built-in engine. XPath 2.0 and 3.0 added features like regular expressions and date functions, but those need a dedicated library like Saxon-JS. For most day-to-day XML querying, 1.0 covers what you need.
How do I select elements with namespaces in XPath?
Namespaces are the biggest headache in XPath 1.0. The browser's evaluate() method needs a namespace resolver, which this tool handles automatically when possible. If a plain query like //element returns nothing, try //*[local-name()='element'] instead. That ignores the namespace prefix entirely and matches on the local tag name.
Is my XML data safe when using this tool?
Yes. The XML you paste stays entirely in your browser tab. Nothing gets sent to a server. The parsing and evaluation happen through JavaScript APIs that run locally, so your data is private even if you're working with sensitive configuration files or internal API responses.