XML tools

XPath testerquery the document you actually have

Run with the button or Ctrl/Cmd+Enter. Choose a result view, then evaluate again when inputs change.

XPath tester

XML input

Result

XML and queries are processed in this browser; no document is sent to a server.

Use an ASCII prefix, e.g. {"b":"urn:books"}; the XML prefix itself may differ.

XPath 1.0; manual execution with Ctrl/Cmd+Enter. Scalar JSON values use strings to preserve NaN and Infinity.

Result is out of date; run again to enable export.

An XPath tester helps when a query works on a small example but stops matching a real XML feed. Often the difference is a default namespace, an attribute condition or the context of a descendant search.

This XPath evaluator keeps the source intact. Use the XPath expression tester to compare nodes with their string values, or test XPath online before carrying the expression into a browser script.

Why use this XPath tester?

See exactly which branches match

The XPath tester separates selected elements from their text. Two title nodes can produce two serialized fragments, two values or two absolute paths; changing views does not silently rewrite the source.

An XML tree with two title branches selected and extracted as two results.

Bind names by their namespace URI

A prefix is only an alias. Bind b to urn:books and query //b:book even when the XML uses a different prefix. Same local names in another namespace remain separate.

Two groups of same-name nodes in different namespaces; only the mapped group is selected.

Three details that change the answer

01

Give the default namespace an alias

For XML with xmlns="urn:books", enter {"b":"urn:books"} and use //b:book. An unprefixed //book only matches elements without a namespace.

02

Compare text with text()

Text view uses the complete XPath string value of each selected node. In mixed content, //title/text() selects direct text nodes while //title with Text view includes descendant text.

03

Check freshness before exporting

Editing XML, the expression, mappings or view disables exports. Run again, including after a view change. Preview shows 50 results at a time; copy and download contain the full successful result.

Select, extract and trace

Four result types

Queries can return a node set, string, number or boolean. count(//book), string(//title) and boolean(//missing) retain their type. JSON values are strings, including numeric NaN and Infinity, so export never silently turns them into null.

Attribute and predicate extraction

Use //book[@id="b1"] to filter elements, //@id to select attributes, and //book[price>15]/title for a numeric predicate. Zero matches are a valid result, with count 0 and an empty values array.

Paths that can be checked again

Paths include sibling positions. Namespaced elements use local-name() and namespace-uri() so the generated path does not depend on your current prefix mapping. Paths are tied to this document; editing its structure can change positions.

Version and input boundaries

XPath 1.0 only
The XPath tester uses the browser engine. XPath 2.0/3.1, matches(), ends-with(), variables and XQuery are outside this page. Namespace-axis results are not portable across browsers.
Strict XML, without repair
Only well-formed XML 1.0 is accepted. DTDs and external entities are rejected; declarations must use UTF-8 when an encoding is specified. HTML is not repaired and whitespace is not formatted away. Adjacent text and CDATA are merged for the XPath data model; serialized nodes may replace CDATA markers with escaped text while preserving the character content.
Explicit namespace aliases
The JSON object maps ASCII prefixes to nonempty namespace URIs. Empty prefixes and xmlns are rejected; xml is reserved for its standard URI. A source prefix containing non-ASCII letters can still be queried with an ASCII alias for the same URI.
Bounded synchronous evaluation
Limits are 100,000 input characters, 2,000 XML nodes including attributes and text, depth 100, 2,000 expression characters, 1,000 matches and 2,000,000 output characters. Exceeding a limit fails the whole result. Native synchronous evaluation has no hard timeout; complex queries can briefly pause the tab.
Source and export scope
Paste XML here; URL import, file upload, saved sharing and schema validation are not provided. Clear and Example show a replacement preview; Apply replaces XML and options, and Undo restores both source and result once.

XPath tester questions

Does this tool support XPath 2.0 or 3.0?

No. The actual evaluator is the browser’s XPath 1.0 engine. Functions such as matches() require a different engine; do not interpret a rejected expression as an XML error.

How do I select elements by attribute in XPath?

Use //book[@id="b1"] to select a book by attribute, or //book/@id to return its attribute value. Attribute names are case-sensitive, and unprefixed attributes do not inherit a default namespace.

What is the difference between / and // in XPath?

A single slash selects the next step directly. A double slash searches descendants from that location: /library/book is anchored to the root, while //book can match books deeper in the document.

Can XPath return text, numbers, or booleans?

Yes. string(//title), count(//book) and boolean(//book) return typed scalar results. Export records the type and a string value; false, an empty string and NaN are successful values, not missing results.

Why does my XPath return zero matches on a namespaced document?

A default namespace also applies to unprefixed element names in XML, but not to unprefixed names in XPath 1.0. Bind an alias to the URI and use that alias in your expression.

Found an unexpected result?

Try your next XPath expression

The XPath tester gives you a repeatable query, explicit namespace bindings and a result whose type is visible. Keep the successful expression alongside the XML sample when investigating a mismatch.