XPath Tester & Evaluator
Developer ToolsPaste XML or HTML and an XPath expression, and see the matching nodes as you type.
Processed in your browser. A copy of each run is saved to your past runs so you can reopen it. Privacy
About
What the XPath Tester does
The XPath Tester evaluates an XPath 1.0 expression against XML or HTML as you type and lists the matching elements, attributes or text, or the number, string or true/false result of functions such as count() and sum(). Switch between nodes and text, bind namespace prefixes for feeds and SOAP documents, and start from examples on a bookstore document. Documents are parsed safely: scripts never run.
Steps
How to use it
- 1Paste XML or HTML, or load the bookstore example.
- 2Type an XPath expression, or pick one from Examples.
- 3Read the matches, switch between Nodes and Text, and copy the result.
Example
A real run
Input
//book[price<10]/title (on a bookstore document with three books priced 30.00, 29.99 and 9.95)
Output
<title lang="en">Learning XML</title> 1 match
Only one book costs less than 10, so the filter keeps a single title element; switch to Text to get just Learning XML.
Options
Every setting, and when to use it
- XML or HTML
- XML mode requires well-formed markup and reports errors. HTML mode parses pages the way a browser does, forgiving unclosed tags, which suits scraping and testing selectors for automation.
- Nodes or Text
- Nodes shows each match as markup, such as <title lang="en">Learning XML</title>; Text shows only its text content. Expressions that return a number, string or boolean show that value.
- Namespaces
- Bind prefixes such as atom=http://www.w3.org/2005/Atom to query documents that use namespaces; a document's own declared prefixes work automatically.
Good to know
Common problems and limits
Documents up to 5 MB. Your browser's XPath 1.0 engine is used, so XPath 2.0 and 3.1 functions such as matches() and string-join() are not available.
The document is parsed into an inert copy that is never displayed, so its scripts never run and its images never load.
For JSON documents, use the JSONPath Tester; to tidy XML first, use the XML Formatter.
Audience
Who uses it
- QA and test automation engineersBuild and check the XPath locators used in Selenium, Playwright or Cypress before putting them in a test.
- Scraping and data developersFind the expression that selects the data you need from a page or a feed.
- Integration developersQuery SOAP responses, sitemaps and XML exports, including namespaced elements.
FAQ
Frequently asked
What is the basic XPath syntax?
/ steps to a child, // searches all descendants, @name selects an attribute and [ ] filters. So //book[price<10]/title finds the titles of books cheaper than 10, and //a/@href lists every link target. Functions such as count(), contains() and text() work inside expressions.
What is the difference between XPath and CSS selectors?
CSS selectors are shorter for selecting elements by class, id and structure. XPath can also move up to parents and ancestors, select text and attributes directly, and filter by text content, which is why test frameworks support both.
How do I test XPath in Chrome DevTools?
Open the Console and run $x("//h1"), which returns the matching elements on the current page. In the Elements panel, Ctrl+F (Cmd+F on a Mac) also accepts XPath expressions.
How is XPath used with Selenium?
With By.xpath("//button[text()='Sign in']") in Java or find_element(By.XPATH, …) in Python. Prefer expressions based on stable attributes such as ids, names or data-test attributes over long positional paths that break when the layout changes.
Why does my XPath return nothing on a document with namespaces?
Elements in a default namespace (xmlns="…") are not matched by an unprefixed name. Bind a prefix to that namespace URI in the Namespaces box, such as atom=http://www.w3.org/2005/Atom, and write //atom:entry.
Is my document sent anywhere?
No. It is parsed and queried in your browser. A copy of each query is saved to your past runs when you copy the result.
Automation: an MCP tool evaluate_xpath(xml, expr) → nodes and an n8n node are planned for this tool.