Skip to main content
L
Loopaloo
Buy Us a Coffee
All ToolsImage ProcessingAudio ProcessingVideo ProcessingDocument & TextPDF ToolsCSV & Data AnalysisConverters & EncodersWeb ToolsMath & ScienceGames
Guides & BlogAboutContact
Buy Us a Coffee
L
Loopaloo

Free online tools for developers, designers, and content creators. Your files are processed in your browser and are never uploaded - no accounts required. A few network utilities (like What's My IP and Currency Converter) call public APIs to do their job and say so on their pages.

support@loopaloo.com

Tool Categories

  • Image Tools
  • Audio Tools
  • Video Tools
  • Document & Text
  • PDF Tools
  • CSV & Data
  • Converters
  • Web Tools
  • Math & Science
  • Games

Company

  • About Us
  • Contact
  • Blog
  • FAQ

Legal

  • Privacy Policy
  • Terms of Service
  • Disclaimer

Support

Buy Us a Coffee

© 2026 Loopaloo. All rights reserved. Built with privacy in mind.

Privacy|Terms|Disclaimer
  1. Home
  2. Document & Text
  3. XPath Tester
Add to favorites

XPath Tester

Test XPath 1.0 expressions against XML as you type, with node-set, number, string and boolean results and automatic namespace prefixes.

Text processed locallyMore document & textJump to full guide
Related readingXML and XPath: Understanding Structured Data and Powerful Queries12 min

Initializing in your browser…

You might also like

Regex Tester & Debugger

Test JavaScript regular expressions live, with highlighted matches, capture groups, replace preview, plain-English explanations and code for eight languages.

XML Formatter & Tools

Format, minify or convert XML to JSON as you type, with line-and-column error checks, a tree view and XPath queries that handle namespaces.

Code Minifier & Beautifier

Minify or beautify JavaScript, TypeScript, CSS, HTML, JSON, XML and SQL as you type, without touching strings or licences, and see the bytes saved.

XPath Tester: a worked example

You are writing a script that reads an Atom feed and your XPath for the authors keeps returning nothing.

Feed and expression

<feed xmlns="http://www.w3.org/2005/Atom"
      xmlns:dc="http://purl.org/dc/elements/1.1/">
  <entry><title>First entry</title><dc:creator>Ada Lovelace</dc:creator></entry>
  <entry><title>Second entry</title><dc:creator>Grace Hopper</dc:creator></entry>
</feed>

//entry/dc:creator
What XPath Tester produces

Result

//entry/dc:creator          node-set, 0 nodes (entry is in the Atom namespace)

//atom:entry/dc:creator     node-set, 2 nodes
  /atom:feed/atom:entry[1]/dc:creator   Ada Lovelace
  /atom:feed/atom:entry[2]/dc:creator   Grace Hopper

The feed declares a default namespace, so its entry elements are not "entry in no namespace", which is what an unprefixed name means in XPath 1.0. The tester binds that namespace to the prefix atom, after the last part of its URI, and with atom:entry the expression finds both creators. Each result carries a path written with the same prefixes, so it can be pasted back in to select exactly that node.

About the XPath Tester

Type an XPath 1.0 expression and see what it selects in your XML as you type: matching nodes with their markup and an exact path, or the number, string or true/false value the expression returns. Namespaces declared in the document are bound for you, including the default namespace.

How it works

XPath is the query language for XML. It is used in XSLT stylesheets, Selenium and Playwright locators, SOAP and RSS processing, configuration tooling and many XML libraries. Writing an expression by trial and error inside an application is slow, so this tester evaluates it instantly against a document you paste, using your browser's built-in XPath 1.0 engine, the same one web pages and many test tools rely on.

All four result types. An XPath expression does not always return elements. //book/title returns a node-set, count(//book) returns a number, string(//title[1]) returns a string, and //book[price > 15] used inside boolean() returns true or false. Many testers ask the engine for nodes only and then show nothing, or an error, for anything else. This one lets the expression decide its own type and shows the answer accordingly: a list of nodes, or the single value, with the result type named. Example expressions are grouped by the type they produce, which is a quick way to learn the difference.

Namespaces without the headache. The most common reason an XPath returns nothing is a namespace. In XPath 1.0 an unprefixed name only matches elements in no namespace, so in an Atom feed, an SVG file or a SOAP envelope with xmlns="...", the expression //entry finds nothing. The tester reads every namespace the document declares, binds the default namespace to a readable prefix (for example atom for the Atom namespace), and lists the bindings so you can write //atom:entry. You can add your own prefix bindings too, for expressions that use different prefixes from the document.

Results you can reuse. Each matching node shows its type, name, its full markup and an absolute path that selects exactly that node, written with the right namespace prefixes so it works when pasted back in. Copy puts all matched markup, or the scalar value, on your clipboard. When an expression is valid but matches nothing, the tool says so plainly and often suggests why, for example a missing namespace prefix. When the XML itself is not well formed, you get the line and column of the problem before any query runs.

Learning aid. A quick reference covers axes and abbreviations (// for any descendant, @ for attributes, .. for the parent), predicates such as [1], [last()] and [@id="x"], node tests such as text() and comment(), and namespace functions like local-name(). Everything runs in your browser, so internal documents stay private.

How to use

  1. 1Paste your XML document, open an XML file, or press Try an example (or Namespaced example for an Atom feed).
  2. 2Type an XPath expression in the box at the top. The result updates as you type.
  3. 3Read the result type and value: a list of matching nodes, or a number, string or boolean.
  4. 4If your document has namespaces, check Namespaces for the prefixes to use, such as atom: for a default Atom namespace.
  5. 5Copy the result, or reuse a node's path as a starting point for a more specific expression.

Key features

  • Instant evaluation as you type, with the browser's XPath 1.0 engine
  • Node-set, number, string and boolean results, each shown appropriately
  • Automatic namespace bindings, including a prefix for the default namespace
  • Custom prefix bindings for expressions written against other prefixes
  • Exact, namespace-aware paths for every matched node
  • Matched markup with node type and name, up to 200 nodes shown
  • Helpful messages for invalid expressions and empty results
  • Line-and-column errors for malformed XML
  • Example expressions grouped by result type and a quick reference
  • Runs locally in your browser

When to reach for this

  • Writing XSLT and XML processing code

    Work out the select expression for a template or a library call against a real sample before putting it in code.

  • Debugging feeds and SOAP responses

    Find out why an expression returns nothing from an RSS, Atom or SOAP document, usually a namespace, and get the prefixed version that works.

  • Test automation locators

    Check XPath locators for Selenium or Playwright against a saved page fragment written as well-formed XHTML.

  • Quick counts and checks

    Count elements, sum values or test for the presence of a node in a configuration or export file without writing a script.

Tips & best practices

  • Wrap a path in count() to see quickly how many nodes it matches.
  • Use normalize-space() when comparing text that may contain line breaks or extra spaces.
  • Prefer specific paths such as /bookstore/book over //book in large documents; // searches the whole tree.
  • Use @* to list every attribute of an element when you are not sure of their names.

Examples

  • Filtering by a child value

    In the example bookstore, //book[price>15]/title returns one node, the title Sapiens, because only that book costs more than 15 (19.99).

  • A number instead of nodes

    count(//book) returns the number 3 and sum(//price) returns 47.97. The result is shown as a single value with its type rather than as an empty node list.

  • A default namespace

    In the namespaced Atom example, //entry finds nothing, while //atom:entry/dc:creator returns Ada Lovelace and Grace Hopper, using the atom prefix the tool binds to the default namespace.

Frequently asked questions

Why does my XPath return nothing?

The usual cause is a default namespace (xmlns="...") on the root element. In XPath 1.0 an unprefixed name matches only elements in no namespace. Use the prefix listed under Namespaces, for example //atom:entry, or match by local name with //*[local-name()="entry"]. Other common causes are case differences, since XML names are case-sensitive, and position predicates such as //title[2], which means the second title within each parent.

Which XPath version is supported?

XPath 1.0, the version built into every web browser and most XML libraries. XPath 2.0 and 3.1 functions, such as matches(), lower-case() or date functions, are not available and produce an error.

What is the difference between //title[2] and (//title)[2]?

//title[2] selects each title that is the second title child of its own parent. (//title)[2] collects every title in the document first and then takes the second one overall. The examples include both so you can compare.

Can I test XPath against an HTML page?

Yes, if the HTML is well-formed XML (XHTML). Typical HTML with unclosed tags such as <br> or <img> is not well formed, and the tester reports the first such problem. Close those tags or use a browser's developer tools for unparsed HTML.

How do I add my own namespace prefix?

Open Namespaces, type a prefix and the namespace URI, and press Add. Your binding is used alongside the ones declared in the document, which is useful when an expression was written for another tool with its own prefixes.

Is my XML uploaded?

No. Parsing and evaluation happen in your browser. The share link stores only the expression.

Related tools and how they differ

  • XML Formatter & Tools: Formats and validates XML, with a simple XPath view alongside the formatted output.
  • JSON Formatter & Validator: Queries JSON with JSONPath, the JSON counterpart of XPath.
  • Regex Tester & Debugger: Matches patterns in plain text when the data is not structured XML.

Further reading

  • XML and XPath: Understanding Structured Data and Powerful Queries12 min read

Private by design

Your text is processed locally in the browser. Nothing you paste or open is transmitted or logged.