Skip to content

XPath Tester

Test XPath 1.0 expressions against pasted XML in your browser. Map namespace prefixes, see the result type, node count, node paths and selected XML or text — with unsafe XML refused before parsing.

Developer Runs client-side Free to use
Jump to the tool
Share: X WhatsApp
Loading XPath Tester…

About the XPath Tester

XPath Tester evaluates XPath 1.0 expressions against XML you paste. The XML is parsed into a separate in-memory document by the browser’s XML parser and queried with the browser’s own XPath engine — it is never added to the page. You see the result type (node-set, string, number or boolean), the number of matching nodes, each node’s kind and path, and the selected XML or text, which you can copy or download.

For namespaced XML, add prefix and URI rows and use the prefixes in your expression; XPath 1.0 has no default namespace, so even a default xmlns needs a prefix. DOCTYPE declarations, entity declarations and processing instructions are refused before parsing, and size, depth, element and result limits keep large documents manageable. The tool works only on pasted XML: it cannot fetch or test a live web page or XML endpoint.

How to use

  1. Paste XML into the box.
  2. Enter an XPath 1.0 expression.
  3. Add namespace prefix mappings if the XML uses namespaces.
  4. Press Run XPath (or Enter).
  5. Review the results, then copy or download them.

Key features

  • Browser XPath 1.0 engine on an isolated document.
  • Editable namespace prefix and URI rows.
  • Node-set, string, number and boolean results.
  • Node kind, path and serialised XML or text.
  • Hostile XML (DOCTYPE, entities, PIs) refused.
  • Clear errors for malformed XML or XPath.
  • Copy Results and Download Results.

Best practices

  • Map a prefix for every namespace you query, including the default one.
  • Use predicates such as [@id='1'] to narrow node-sets.
  • Use string(), count() or boolean() for single values.
  • Remove DOCTYPE lines before pasting; they are not needed for XPath.
  • Test with representative samples before using an expression in code.

Benefits

  • Quick feedback while writing XPath for scrapers, tests or XSLT.
  • Safe handling of untrusted XML.
  • Paths make it easy to see where each match lives.
  • Private: nothing is uploaded or stored.

Frequently asked questions

Which XPath version is supported?

XPath 1.0, as provided by your browser. XPath 2.0 and 3.1 functions and types are not available.

How do I query XML with a default namespace?

XPath 1.0 cannot use a default namespace directly. Add a row mapping a prefix such as a to the namespace URI, then write //a:item instead of //item.

Can it test a live web page or XML URL?

No. It only queries the XML you paste. Nothing is fetched from the internet.

Why is my XML rejected?

DOCTYPE and entity declarations and processing instructions are refused for safety, and malformed XML reports the line and column of the problem. Remove the DOCTYPE line and try again.

What result types can I get?

A node-set (elements, attributes, text or comments), or a single string, number or boolean from expressions such as string(//title), count(//item) or boolean(//error).

What are the limits?

Up to 2 MB of XML, 100,000 elements, 256 levels of nesting, 1,000-character expressions and the first 1,000 matching nodes.

Is anything I paste uploaded or saved?

No. Everything is processed in your browser on your device. Nothing is uploaded, no request is sent, and inputs and results are not saved in browser storage. Reset clears them from the page.