XPath Tester

Test XPath expressions


          

What Is This Tool?

The XPath Tester evaluates an XPath expression against an XML document and lists every matching node or value. It uses your browser's native document.evaluate XPath engine, so results match how XPath behaves in real browser-based XML processing. Everything runs locally — nothing is uploaded.

How to Use

1

Paste your XML into the input box.

2

Enter an XPath expression, such as //item[@id='2'].

3

Click Evaluate.

4

Review each matched node's text or value in the results list.

Features

  • Supports node-set, string, number, and boolean XPath results
  • Lists every matching node, not just the first
  • Clear error messages for invalid expressions
  • Uses the browser's native XPath engine
  • 100% client-side — nothing leaves your browser

Examples

XML:

<items>
  <item id="1"><name>Widget</name></item>
  <item id="2"><name>Gadget</name></item>
</items>

XPath: //item[@id='2']/name

Result: a single matched node with text content "Gadget".

Common Use Cases

  • Building and debugging an XPath selector before using it in code
  • Extracting specific values from a large XML document
  • Verifying an XML feed's structure matches expected selectors
  • Learning XPath syntax with immediate, visible feedback

Frequently Asked Questions

Is my XML uploaded anywhere?

No. Evaluation happens locally using your browser's built-in document.evaluate XPath engine. Nothing is sent to a server.

What XPath version is supported?

This tool uses the browser's native XPath 1.0 implementation, the same engine used for document.evaluate in JavaScript.

What if my expression returns a number or boolean instead of nodes?

The tool detects the result type automatically and shows a string, number, or boolean value instead of a node list when appropriate.

What happens if my XPath expression is invalid?

The browser throws a DOMException for a malformed expression, and this tool displays that error message instead of failing silently.

What happens if my XML isn't well-formed?

The tool checks for a parser error first and reports it, since XPath cannot be evaluated against invalid XML.

Does this support XML namespaces?

Basic default-namespace documents usually work, but expressions using explicit namespace prefixes may need adjustment since no namespace resolver is configured.