XPath Test Tool

Test and validate XPath expressions against XML documents. Debug queries, view matched nodes, and learn XPath syntax with interactive examples.

XML Document
Results

Enter an XPath expression and click Evaluate

Test XPath Expressions

Validate and debug XPath queries against your XML documents. See matched nodes instantly and learn XPath syntax with interactive examples.

Why Use This Tool?

Instant Testing

Evaluate XPath expressions instantly and see results in real-time.

Sample XPaths

Learn with pre-built examples covering common XPath patterns.

Error Detection

Get clear error messages for invalid XML or XPath syntax.

Multiple Result Types

Handle nodes, text, numbers, and boolean results seamlessly.

How this XPath Test Tool works

This XML query testing tool evaluates XPath expressions against XML documents using the browser's native XPath engine. Users paste XML content and enter XPath queries, receiving matched nodes, text content, or calculated values instantly based on expression type.

The evaluator supports XPath 1.0 including node selection (//book), attribute access ([@id]), predicates ([price>30]), functions (count(), text(), contains()), and axis navigation (preceding-sibling, ancestor). Sample expressions with descriptions help users learn XPath syntax through practical examples.

Results display matched nodes as serialized XML, text content for text() selections, or numeric/boolean values for aggregate functions. Error messages identify syntax problems or parsing failures with helpful context. The tool validates XML structure before query execution, flagging malformed documents.

How to Use

1

Enter XML

Paste your XML document or use the sample provided.

2

Write XPath

Enter an XPath expression to query the XML document.

3

View Results

See matched nodes, values, or errors with helpful messages.

Example Usage

Finding book titles in the "web" category:

Input
XML: <bookstore>...</bookstore> XPath: //book[@category="web"]/title
Output
<title lang="en">Learning XML</title> <title lang="en">XQuery Kick Start</title>

Frequently Asked Questions

What is XPath?
XPath (XML Path Language) is a query language for selecting nodes from XML documents. It uses path expressions to navigate through elements and attributes.
Does this support XPath 2.0 or 3.0?
This tool uses the browser's built-in XPath 1.0 implementation. Most common expressions work, but some XPath 2.0+ features may not be available.
Can I use this with HTML?
Yes, but HTML must be well-formed XML (XHTML). Regular HTML with unclosed tags may cause parsing errors. Consider using an HTML parser first.
What XPath functions are supported?
Common functions include: text(), contains(), starts-with(), count(), sum(), position(), last(), not(), and boolean operators (and, or).
Is my data secure?
Yes. All XPath evaluation happens in your browser using the native DOMParser and XPathEvaluator APIs. No data is sent to any server.

Related Tools

The XPath Test Tool is maintained by CodeItBro. We aim to provide the best free developer tools on the web. If you have feedback or suggestions, please visit our contact page.