XPath Tester

XPath Tester

Evaluate XPath expressions against XML and inspect node, text, number, and boolean results.

Input

XPath Output

About The XPath Tester

The XPath Tester evaluates XPath expressions against pasted XML and reports node, string, number, or boolean results. It is useful for checking extraction rules before using them in scrapers, integrations, XML transforms, QA checks, or API response tests.

The query runs in your browser using the browser's XML and XPath support. XPath behavior can vary slightly across environments, especially for namespaces and result typing, so verify critical expressions in the same runtime your project uses.

How to Test XPath Online

  1. Paste XML into the XML input area.
  2. Enter an XPath expression such as //book/title/text().
  3. Click Run Query to evaluate the expression.
  4. Open Show more options when you need a specific result type or namespace mappings.
  5. Use Load sample to test a realistic XML document with a predicate-based query.

Choosing Options Correctly

Result type:
Leave this on Auto for normal checks. Choose Nodes, String, Number, or Boolean when you need to test how an expression behaves in a specific XPath result mode.

Namespaces:
Add one mapping per line as prefix=URI. Then use that prefix in your XPath expression, even if the XML uses a default namespace.

Common Use Cases

  • Check whether an XPath selector returns the expected XML nodes.
  • Debug namespace issues before writing parser code.
  • Test predicates such as //book[price > 30]/title/text().
  • Confirm whether an expression should be treated as a node list, string, number, or boolean.

Quick FAQ

Why does my XPath return no nodes?
Common causes are namespaces, wrong root context, case-sensitive element names, or querying text when the XML uses attributes.

Does this validate XML schemas?
No. It evaluates XPath against parsed XML and does not validate against XSD or DTD rules.

Does this run locally?
Yes. XPath testing is designed to run in the browser.

How should I handle namespaces?
Use the namespace-aware syntax supported by the tool, or simplify a copy of the XML when debugging namespace-heavy documents.