XPath Tester
Evaluate XPath 1.0 expressions against pasted XML with highlighted matches, typed results, and session history.
XML document
Results
Paste XML, then write an XPath 1.0 expression
Matches highlight in place as you type. Nothing leaves your browser.
Details
The XPath Tester evaluates expressions against pasted XML using your browser's native XPath 1.0 engine (document.evaluate), so results match what a real scraper or pipeline sees — no approximation layer. Node-set results are listed in a typed table and highlighted directly in the source, namespaced documents work with a prefix-to-URI map you can auto-detect from the document's xmlns declarations, and string, number, and boolean results render as typed cards. Expressions are kept in a per-device session history for instant re-runs, and an HTML mode lets you test selectors against tag-soup pages. Your XML and expressions never leave the browser.
More examples
Selecting elements with a predicate
XML: <item id="3"><price>9.90</price></item>
XPath: //item[@id='3']/priceMatches are listed in the results table and highlighted directly in the source, so you can verify at a glance which nodes the selector hits.
Querying a namespaced document
Namespaces: saml=urn:oasis:names:tc:SAML:2.0:assertion
XPath: //saml:NameID/text()Prefixes must be declared in the namespace map (or auto-detected). Unprefixed names never match a default xmlns in XPath 1.0.
Function results
count(//item)
string(//title)
contains(//title, 'launch')Node-set, string, number, and boolean results are all rendered with their type shown, mirroring XPathResult types.
Examples
Predicate selection
//item[@id='2']/title/text()Second item about naïve cachingA predicate picks one item out of several; the text node result is shown as a string and its location is highlighted in the source.
Namespaced lookup
map: saml=urn:oasis:names:tc:SAML:2.0:assertion → //saml:NameID/text()ada@example.comThe prefix in the expression is resolved through the namespace map, exactly like a real SAML parser would.
Counting and asserting
count(//widget)3 — number cardFunction results return typed primitives, ideal for asserting values in XML test fixtures before writing the automation.
About this tool
The XPath Tester evaluates expressions against pasted XML using your browser's built-in XPath 1.0 engine (document.evaluate) — the same engine a page's own JavaScript would run. That matters for debugging: there is no re-implementation or approximation layer between your expression and the result, so what you verify here is what your scraper, pipeline, or test assertion will see. Every result is computed locally; the document and the expression never leave the tab.
Node-set results do two jobs at once. They are listed in a results table — ordinal, node name, and a value snippet — and they are highlighted directly inside your pasted source, with the matched regions marked in place. The highlight index is computed by scanning the original source text and matching locator keys against the parsed DOM, so marks land on the exact substrings you pasted, not on a re-serialized approximation. Clicking a row scrolls the source to that match. String, number, and boolean results (string(//title), count(//item), contains(…)) render as typed cards, so you always know which XPathResult type came back.
Namespaces are where most XPath debugging stalls, and the tool treats them first-class: a prefix-to-URI map applies to every evaluation, and the Detect namespaces button scans your document's xmlns declarations and fills the map for you — one click instead of hunting URIs by hand. A default-namespace notice explains the classic XPath 1.0 trap: unprefixed names never match elements in a default xmlns, so you need to declare a prefix for it. Session history keeps your last 20 expressions per device for one-click re-runs, and expressions can be shared via URL — the expression travels in the link, never the document.
Two boundaries are stated up front. The engine is XPath 1.0 — that is what every browser ships — so XPath 2.0+ functions such as matches() or for … return are not available. And an HTML mode parses input with the browser's tag-soup HTML parser instead of the strict XML parser, which is useful for testing selectors against real pages but produces results that can differ from an XML engine.
What this tool does not do
- XPath 1.0 only — the browser API defines what is possible, so 2.0+ functions and schema-aware matching are unavailable.
- Highlighting covers elements, text nodes, attributes, and comments; exotic node kinds fall back to the table, which always lists every match.
- HTML mode uses the browser's forgiving HTML parser, so its results can legitimately differ from strict XML parsing.
How to use this tool
Paste XML and write an expression
Paste or upload your document (up to 5 MB), type an XPath 1.0 expression in the bar, and results update as you type.
Read the typed result
Node sets list every match with name and value and highlight in the source; string, number, and boolean results show as typed cards.
Resolve namespaces
Click Detect namespaces to fill the prefix=URI map from the document's xmlns declarations, then use those prefixes in the expression.
Iterate with history and sharing
Mod+Enter runs; the history dropdown re-runs recent expressions instantly; copy results as text or JSON, or share the expression via the URL.
Use cases
Verifying scraping selectors
Test the exact expressions a scraper will run against a real page fragment — in HTML mode if the source is tag soup — before wiring them into production code.
Debugging SAML and SOAP responses
Auto-detect the namespace map from xmlns declarations and pull out assertion values, status codes, or NameIDs without a desktop XML IDE.
Asserting values in XML test fixtures
Use count(), string(), and boolean expressions to confirm what an assertion will evaluate to before committing it to a test suite.
Result types the XPath 1.0 engine returns
| Expression shape | Result |
|---|---|
| //item, /root/child, (//a | //b)[1] | Node set — table of matches plus in-source highlighting |
| string(//title) | String — rendered as a string card |
| count(//item), position() | Number — rendered as a number card |
| contains(//t, 'x'), //a = //b | Boolean — rendered as a boolean card |
| //saml:Issuer with saml=urn:… map | Prefixed node set — resolved through the namespace map |
| //item with default-xmlns document | Empty unless a prefix for the default namespace is declared and used |
The engine is the browser's XPath 1.0 implementation; XPath 2.0+ functions are not available.
Common mistakes
Mistake:Using unprefixed names against a document with a default xmlns.
Fix:XPath 1.0 never matches unprefixed names to a default namespace. Declare a prefix (d=the URI) in the map and query //d:item instead of //item — the tool warns when this is likely the cause of zero matches.
Mistake:Expecting XPath 2.0/3.1 functions.
Fix:Browsers only ship XPath 1.0. matches(), for … return, and regular expressions do not exist here; use 1.0 equivalents such as contains() or starts-with().
Mistake:Writing an expression before the XML parses.
Fix:A malformed document disables the expression bar — fix the syntax error shown in the results panel first; the parser message points at the problem.
Frequently asked questions
Which XPath version does the browser support?
XPath 1.0 — that is the version every browser's document.evaluate API implements, and it is what this tool runs, so results match what in-page scripts and most scraping setups see. XPath 2.0 and 3.1 features such as matches(), regular expressions, or for … return expressions are not available; use 1.0 equivalents like contains() or starts-with(). The limitation is stated in the interface so you are never surprised by a missing function.
How do I query namespaced XML?
Click Detect namespaces and the tool scans your document's xmlns declarations and fills the prefix=URI map automatically — or type the lines yourself, one per line. Then use the declared prefixes in the expression, e.g. //saml:NameID once saml=urn:oasis:names:tc:SAML:2.0:assertion is in the map. Documents without namespaces need no map at all.
Why do unprefixed names match nothing in a document with xmlns="…"?
That is a deliberate XPath 1.0 rule: unprefixed element names always resolve to no namespace, so they never match elements declared in a default xmlns. The fix is to declare a prefix for that URI in the namespace map (d=urn:example, say) and query //d:item instead of //item. The tool detects this situation and shows a warning when it is likely the reason you got zero matches.
Why do my matches highlight incorrectly on big files?
Highlights are capped at 200 marks so the page stays responsive on large documents; beyond that the results table still lists every match up to 1,000 rows with a counter. The highlight index is computed from your original source text rather than a re-serialization, so marks land on the exact substrings you pasted. If a specific node cannot be located in the source, the table remains the authoritative list.
What result types can XPath return here?
All four XPath 1.0 result kinds: node sets (rendered as a table with ordinal, node name, and value, plus in-source highlighting), strings, numbers, and booleans (rendered as typed cards). The panel header shows which type came back, and the type follows the standard XPathResult classification — count(//item) is a number, string(//title) a string, contains(//a, 'x') a boolean, and //item a node set.
Can I test HTML pages?
Yes — turn on HTML mode and the input is parsed with the browser's HTML parser instead of the strict XML parser, so unclosed tags and other tag soup still load. The results then reflect how a browser script querying that DOM would behave, which is exactly what you want for scraping selectors. Keep in mind the HTML parser repairs documents, so results can differ from an XML engine on the same source; a caveat in the interface reminds you whenever the mode is active.
References & standards
Related tools
Base32 Encoder / Decoder
Encode and decode Base32 (RFC 4648) with hex input mode and Crockford variant. Handles TOTP secrets. Runs in-browser.
Base58 Encoder / Decoder
Convert hex or text to Base58 and back, with Base58Check validation (version byte + checksum). IPFS CIDs too. In-browser.
Base64 Toolbox
Professional Base64 workspace for text, files and images with Base64URL, MIME, Data URI, strict validation, image preview and ready-to-use snippets.
BibTeX to JSON Converter
Parse .bib bibliographies into structured JSON with authors, months, macros and LaTeX cleanup, all in-browser.
C# to VB.NET Converter
Convert a subset of C# — classes, methods, variables, loops — into VB.NET
CSV Data Viewer
Paste CSV and inspect it as a sortable, searchable table with delimiter detection and inline export.