Trexmi
Developer Ready

XPath Tester

Evaluate XPath 1.0 expressions against XML and inspect matched nodes or typed string, number, and boolean results.

Evaluate XPath 1.0 expressions Return element, attribute, text, and comment nodes Return string, number, and boolean results Serialize every matched node
The server uses DOMXPath and XPath 1.0. XPath 2.0 and 3.x functions are not available.
INPUT Developer source value *
0 chars0 words0 lines
Paste the source value for this specific transformation. Example: <catalog><item id="1">Trexmi</item></catalog>

Tool settings

Ctrl / ⌘ + Enter
XPath result Matched nodes or a typed scalar result as readable JSON.
About the tool

What XPath Tester does

XPath Tester evaluates an XPath 1.0 expression against XML. Location paths return a node list with each node name, type, string value, and serialized XML. Functions such as count(), string(), and boolean() return a typed scalar result instead.

The server uses PHP DOMXPath, so the supported language is XPath 1.0 rather than XPath 2.0 or 3.1. Namespace declarations on the document element are registered automatically. A default XML namespace is available through the synthetic prefix default, because unprefixed XPath names match elements in no namespace.

XPath Tester evaluating an XPath 1.0 expression against XML
Evaluate node paths and scalar XPath functions against the same visible XML source.

How to use

  1. Add valid XML. Keep the smallest complete document that reproduces the path you need.
  2. Enter an XPath expression. Start with a direct path, then add predicates, attributes, functions, or axes.
  3. Handle namespaces. Reuse declared prefixes. For a default namespace, write expressions such as //default:item.
  4. Inspect the result type. Node sets include serialized matches; scalar functions return a string, number, or boolean.
  5. Test boundaries. Check zero matches, repeated nodes, missing attributes, and alternate namespace documents.
Built for the task

Why use XPath Tester?

Focused controls, predictable output, and a workflow designed around this exact transformation.

01

Node-level inspection

See every matching node with its name, value, node type, and serialized XML.

02

Typed expressions

Evaluate count, string, and boolean expressions instead of forcing every result into a node list.

03

Namespace support

Use declared prefixes and a documented default prefix for namespaced XML.

04

Safe XML parsing

External network access is disabled while the test document is parsed.

Useful answers

Questions about XPath Tester

Practical details about input, output, privacy, limits, and the best way to use this tool.

01 Which XPath version does the tester support?

It uses PHP DOMXPath and supports XPath 1.0 expressions. XPath 2.0 and 3.x-only functions are not available.

02 Can the result be a number or boolean?

Yes. Expressions such as count(//item) and boolean(//item) return typed scalar results.

03 Why does an unprefixed path miss default-namespace elements?

In XPath 1.0, an unprefixed element test matches no namespace. Use the synthetic default prefix registered by this tool.

04 Can I select attributes and text nodes?

Yes. Use expressions such as //user/@id or //message/text(). Node results include their values and serialization.

05 What does zero matches mean?

The XML and expression can both be valid while no nodes satisfy the location path. Check names, case, predicates, hierarchy, and namespaces.

06 Does the tool load external entities or remote XML resources?

Network access is disabled for XML parsing. The tool evaluates only the supplied document and does not fetch linked resources.

07 Can I use XPath variables or custom extension functions?

No. The tester does not bind application variables or register custom PHP functions.

08 Why should I retest in my application?

Your destination may use a different XPath version, namespace bindings, parser flags, document context, or extension functions.

Examples

Filter elements by attribute

A predicate filters product elements before the child name is selected.

Input
XML: AlphaBeta
XPath: //product[@status="active"]/name
Output
result_type: nodes\ncount: 1\nmatch name: name\nmatch value: Alpha

Return a numeric count

DOMXPath evaluate returns a typed number for count instead of a node list.

Input
XML: 
XPath: count(//product)
Output
result_type: number\nvalue: 3

Read an attribute value

The string function returns the attribute value as a scalar.

Input
XML: Ada
XPath: string(/users/user/@id)
Output
result_type: string\nvalue: 42

Query a default namespace

The tool registers the root default namespace under the prefix default.

Input
XML: Ready
XPath: //default:item
Output
result_type: nodes\ncount: 1\nmatch value: Ready

XPath 1.0 paths, axes, and predicates

A location path selects nodes from the XML tree. /catalog/product follows an absolute child path, while //product selects matching descendants. Predicates narrow a node set: //product[@status="active"] checks an attribute and //product[price > 20] compares a child value.

Positions are one-based. //product[1] does not mean array index zero; its exact scope also depends on the location step. Test positional expressions against repeated groups rather than assuming JavaScript-style indexing.

Strings, numbers, and booleans

XPath 1.0 expressions return one of four core types: node set, string, number, or boolean. This tester preserves that distinction. Use string() when you want one text value, count() for a number, and boolean() for an existence check.

Values such as XPath NaN or Infinity cannot be represented as native JSON numbers, so they are returned as named strings while the result type remains number.

XML namespaces and the default prefix

XPath matches expanded names, not only the visible tag text. Prefixes declared on the document element are registered for the expression. When the XML uses a default namespace, use default: in the test expression. Declarations introduced only on deeper elements may require a different test document or explicit bindings in the destination application.

Implementation limits and verification

The tool does not provide XPath 2.0 sequences, regular-expression functions, date types, maps, arrays, XQuery, XSLT, custom variables, or extension functions. Large result sets are serialized into the response, so narrow production-sized documents with a predicate when possible.

Check malformed XML first with XML Validator. Then verify the final expression in the exact library and runtime that will execute it.

Official XPath references

Review the W3C XPath 1.0 Recommendation and the PHP DOMXPath evaluate documentation.