How do I test XPath expressions against XML online?
Paste your XML into the editor, type an XPath expression like //book[@category='programming']/title, and click Evaluate to see matching nodes instantly. The tool supports element selection, attribute filtering, axes (ancestor, descendant, sibling), and XPath functions (count, contains, starts-with). Click any example query button to try common patterns. Everything runs in your browser using the native XPath 1.0 engine — no data is sent to a server.
XPath Tester
Test XPath expressions against XML data with real-time evaluation. Extract elements, filter by attributes, and navigate XML document structures.
XPath Reference
| Expression | Description |
|---|---|
/ | Root element |
//element | All matching elements anywhere |
./child | Direct child of context |
@attr | Attribute value |
[1] | First element (1-indexed) |
[last()] | Last element |
[position()<3] | First two elements |
[@attr='val'] | Filter by attribute |
[contains(., 'text')] | Contains text |
[starts-with(@id, 'x')] | Starts with |
text() | Text content |
node() | Any node |
count(//el) | Count elements |
sum(//el) | Sum of numeric values |
string-length(//el) | String length |
ancestor::el | Ancestor axis |
descendant::el | Descendant axis |
following-sibling::el | Following siblings |
parent::el | Parent axis |
el1 | el2 | Union of two node sets |
About XPath
XPath (XML Path Language) is a query language for selecting nodes from XML documents. It uses path expressions to navigate through elements, attributes, and text in an XML tree structure.
- Nodes — elements, attributes, text, comments, and the document itself
- Axes — define the direction of navigation (child, parent, ancestor, descendant, sibling)
- Predicates — filter nodes with conditions inside square brackets
- Functions — built-in string, number, and node functions (contains, count, sum, etc.)
XPath is used in XSLT, XQuery, web scraping (Selenium, Puppeteer), configuration parsing, and XML data extraction. This tool uses your browser's built-in XPath 1.0 engine — no data is sent over the network.
Frequently Asked Questions
What is XPath and how does it work?
What is the difference between XPath and JSONPath?
How do I select elements by attribute value in XPath?
Is it safe to paste XML data into this tool?
Related Inspect Tools
Diff Checker
Compare two texts and see differences highlighted
Cron Expression Parser
Parse cron schedules into plain English with next run times
Word & Character Counter
Count words, characters, sentences, and estimate reading time
Chmod Calculator
Calculate Unix file permissions with an interactive permission matrix