XP

XPath Tester

Query XML with XPath 1.0, namespace bindings and complete typed results

JSON & Data
πŸ”’ 100% client-side β€” your data never leaves this page
Maintained by Evanβ€’Updated: September 30, 2026

Process XML 1.0 locally, with namespaces, comments, CDATA and processing instructions. DTD and entity declarations are unsupported. Input stays in this page; drafts are not stored. Limits: 1 MiB input, 4 MiB output, 20,000 XML nodes including attributes, 64 element levels. Textareas normalize pasted line endings; upload UTF-8 to retain original CSV carriage returns.

XML 1.0

XML only. A default namespace needs an explicit query prefix. Results include strings, numbers, booleans and up to 2,000 nodes; copy/download contains complete typed JSON, including full serialized elements. Non-finite XPath numbers are strings inside a number result.

Page reading mode

The full guide also includes pitfalls, worked examples, snippets, FAQs, and related tools for checking results or troubleshooting.

About this tool

XPath Tester evaluates browser-native XPath 1.0 against XML 1.0. Enter one prefix=URI per line to query namespaced elements; documents with a default namespace also need a query prefix. Node sets, strings, numbers and booleans have distinct typed results. Copy and download contain complete result JSON, with full serialized XML for elements, namespace bindings needed by each subtree, and untrimmed attribute/text values. A valid query with zero matches is an empty result. Non-finite XPath numbers are represented as strings within a number result. Expressions are limited to 2,048 characters, namespace settings to 32 lines and 8,192 characters, and matches to 2,000 nodes. HTML parsing, DTD, XPath 2/3 and the namespace axis are outside this tool’s scope. Input is limited to 1 MiB, output to 4 MiB, XML to 20,000 nodes including attributes and 64 element levels. UTF-8 uploads use strict decoding; pasted text follows the browser textarea line-ending rules. Processing runs locally, and draft input is not saved.

Scenario Recipes

01

Query a feed with a default namespace

Goal: Distinguish a namespace mismatch from a valid empty result.

  1. Paste the XML feed and inspect its xmlns value.
  2. Bind p to that URI, then compare count(//p:item), //p:item/@id and string(//p:item[1]).
  3. Copy complete result JSON and inspect values and result types. Zero nodes is a valid result; an invalid expression is reported separately.

Result: A reproducible XPath 1.0 query with explicit namespace settings.

Failure Clinic (Common Pitfalls)

The expression returns zero nodes

Cause: The element may be namespaced, or the path may select no records.

Fix: Check the expanded element name and bind a prefix. Keep a valid zero-match result separate from syntax errors.

A result looks shortened in the browser

Cause: The visual preview is capped at 40,000 characters.

Fix: Use Copy complete result JSON or Download JSON. Both contain all accepted matches up to the node and output limits.

Production Snippets

Bind a prefix even when the document uses a default namespace

xml

<catalog xmlns="urn:catalog"><item id="001">  A  </item></catalog>

Namespace: p=urn:catalog
XPath: count(//p:item)
Result JSON: {"type":"number","value":1}

Frequently Asked Questions

Why does //item not match a default namespace?

In XPath 1.0, unprefixed element tests select elements without a namespace. Bind p=urn:catalog and use //p:item when that URI is the document namespace; the query prefix need not match the source prefix.

Can I evaluate count(), string() and boolean()?

Yes. They return number, string and boolean results. NaN and infinities are kept as text values with result type number because JSON has no non-finite numeric literal.

Does Copy include only the preview?

No. Copy and download include the complete typed result JSON, even when the visible preview is truncated. Element values contain full XML; attribute and text values retain their whitespace.

Can I query HTML or use XPath 2.0?

No. This tool parses strict XML 1.0 and uses the browser XPath 1.0 engine. Convert HTML with an appropriate parser or use another XPath engine for those workflows.

Keep browsing