XPath Tester

XML documents store data in nested elements, and finding a specific piece often means writing code to walk the tree by hand. XPath is the query language designed for exactly that job: a short expression describes a path through the document, and every node matching that path is returned. Developers use XPath to extract values from feeds, configuration files and API responses, and to test selectors before embedding them in scraping or transformation code. This tester evaluates an XPath expression against pasted XML and shows the matching nodes and their text immediately, so you can refine an expression interactively instead of guessing and re running a script. In a full browser it uses the native XPath engine, with a built in fallback for the most common path forms.

Quick Answer: Paste XML, type an XPath expression such as a double slash path to an element, and click Evaluate to see every matching node.

Free Online Tool

XPath Tester

Evaluate XPath against XML, with match text and count.




How to Use the XPath Tester

  1. Paste a well formed XML document into the input box.
  2. Type the XPath expression you want to test, starting with a path to the elements you need.
  3. Click Evaluate XPath to run the expression against the document.
  4. Read the match list, which shows each matching node’s text and how many nodes matched in total.
  5. Refine the expression, for example by adding an attribute filter or an index, and evaluate again.

Key Features

  • Native XPath evaluation in browsers that support it, covering the full expression language.
  • Fallback evaluation for common path forms, including descendant paths, child paths, attribute filters and indexes.
  • Match counting, so you can confirm an expression selects exactly the nodes you intended.
  • Text extraction for each match, showing the value rather than just a node count.
  • Clear error reporting when the XML is malformed or the expression cannot be evaluated.

Best Practices and Tips

  • Start broad with a descendant path, confirm the matches, then narrow with filters rather than writing a complex expression first.
  • Use an attribute filter when elements share a name but differ by an identifier or type attribute.
  • Remember that indexes in XPath count from one, not zero, so the first matching element is index one.
  • Test expressions against a small sample document first, then apply them to the full feed or file.

Common Mistakes to Avoid

  • Forgetting that a path starting with a single slash is absolute from the document root, while a double slash searches all descendants.
  • Using a zero based index, which selects the second element when the first was intended.
  • Testing against malformed XML, where a missing closing tag makes the whole document unparseable rather than just one branch.

Frequently Asked Questions

What is XPath?

XPath is a language for selecting nodes in an XML document. An expression describes a path, such as all item elements anywhere in the document, or the title child of a specific element. It is used in data extraction, document transformation and automated testing of XML based systems.

Which expressions does the fallback support?

When a browser lacks native XPath support, the built in fallback handles the most common forms: descendant paths, child paths, attribute equality filters, and numeric indexes. Complex axes, functions and predicates beyond those forms need a browser with native XPath evaluation, which most desktop browsers provide.

Why does my expression return no matches?

The usual causes are a wrong element name, case sensitivity,since XML names are case sensitive, a path that assumes a different nesting level, or an attribute filter whose value does not match exactly. Start with a broad path and narrow it step by step to find where the mismatch appears.

Can I test against HTML?

This tool is designed for well formed XML. HTML from the web is often not well formed, with unclosed tags and other leniencies, so it may fail to parse. For HTML extraction, convert the page to well formed markup first, or use a dedicated HTML parser.

Related Tools