AIWalay Tools

XPath Tester

Test XPath expressions against your XML and see matching nodes, attributes or values instantly. Namespace-aware, uses the browser's XPath engine. Free.

About the XPath Tester

This XPath tester lets you run XPath expressions against an XML document and see exactly what they match. Paste your XML, type an expression like //book[@id='2']/title or count(//item), and get the matching nodes, attribute values or computed result immediately.

It uses the browser's native XPath engine, so it supports the standard XPath 1.0 functions and axes you'd expect — predicates, attribute selectors, count(), text() and more. Element and attribute matches are serialized and listed with a match count, while numeric, string and boolean expressions show their computed value directly.

It's namespace-aware: prefixes declared on the document's root element resolve automatically, and a default namespace can be addressed with the prefix 'ns'. Errors — malformed XML or an invalid expression — are reported clearly so you can iterate quickly. Everything runs locally in your browser.

How to Use the XPath Tester

  1. 1Paste your XML document into the first box.
  2. 2Enter an XPath expression in the expression field.
  3. 3Click Evaluate XPath.
  4. 4Review the matched nodes or computed value, and copy what you need.

Frequently Asked Questions

Which version of XPath does this support?

It uses the browser's built-in XPath engine, which implements XPath 1.0. That covers the vast majority of everyday needs — predicates, axes, and functions like count(), text(), contains() and starts-with(). XPath 2.0/3.1-only features aren't available in browsers.

How do I query XML that has a namespace?

Prefixes declared on the root element resolve automatically. If your document has a default namespace (an xmlns without a prefix), address those elements using the prefix 'ns' in your expression — for example //ns:item — since XPath 1.0 can't match unprefixed default-namespace elements otherwise.

Can it return values, not just nodes?

Yes. Expressions that compute a number, string or boolean — like count(//book) or //title/text() — show their result directly. Node-set expressions list each matching element or attribute along with a total match count.

Why does my expression match nothing?

The most common reasons are case sensitivity (XPath element names are case-sensitive), a namespace on the document that needs the ns: prefix, or a predicate that doesn't match any node. Check the XML is well-formed too — the tester reports parse errors if it isn't.

Related Tools