XPath Tester
Evaluate XPath on XML or HTML with typed results, node paths and XML namespace mappings.
How to use
- Choose XML or HTML and paste a document, or load Sample. Enter an XPath 1.0 expression; results update after a short pause.
- For XML namespaces, enter one prefix=URI mapping per line. Even a default namespace needs a prefix in the expression.
- Inspect the result type and match count. Expand a node to copy its path, text or serialized markup. Scalar expressions return a string, number or boolean.
- Inputs are limited to 5 MB of UTF-8 text. Only 500 nodes are displayed; long node previews are marked as truncated. Use the cheat sheet for axes, predicates and functions.
FAQ
Which XPath version does this evaluator support?
It uses the browser’s native XPath 1.0 evaluator. XPath 2.0 and 3.1 functions such as matches() are not available. HTML parsing repairs malformed markup and adds html, head and body elements.
Why does my XML XPath return no matches?
Elements in a default XML namespace still need an explicit prefix in XPath. For <catalog xmlns="urn:books">, add b=urn:books and query /b:catalog. Prefix mappings are ignored in HTML mode.
Does pasted HTML run scripts or save my input?
No. Parsing uses an isolated, script-disabled realm with a deny-all resource policy. Results are displayed as text, never rendered as HTML. Only the XML/HTML mode is saved; source, expressions and namespace mappings remain in memory.
What limits apply to large documents?
The source limit is 5,000,000 UTF-8 bytes. All matches are counted, but only 500 nodes are shown. Each node’s text and markup preview is capped at 20,000 characters; copies and downloads contain those previews. XML DTD declarations are not supported. Complex XPath expressions can still take time on the browser’s main thread.