Test XPath expressions on XML, HTML, XHTML or SVG in your browser. See every matching node, attribute or text, or the value of count() and string(). Uses the browser's built-in XPath 1.0 engine, shows the match count, and resolves namespace prefixes from the document.
XPath (XML Path Language) is a query language for selecting parts of an XML or HTML document: elements, attributes, text, or computed values such as counts. It is used in XSLT, Selenium and Playwright locators, web scraping and many XML APIs. This tool runs your expression with the browser's own XPath engine and shows exactly what it selects.
text/html, text/xml, application/xml, application/xhtml+xml or image/svg+xml.//city/name, and press Enter or click Select.count(), string(), comparisons) are shown as a single valuename="value", text nodes as plain textlocal-name()For the sample document of <city> elements with <name> and <population> children:
| Expression | Selects |
|---|---|
//city | Every city element |
//city/name/text() | The text of each city name |
//city[1]/name | The name of the first city |
//city[population > 5000000]/name | Names of cities with more than 5 million people |
count(//city) | The number of cities (a number result) |
//*[local-name()='name'] | Every name element, ignoring namespaces |
//a/@href | Every href attribute of links (HTML) |
When the root element declares a default namespace, unprefixed names in XPath 1.0 only match elements with no namespace. Use //*[local-name()='item'], or choose text/html if the document is really HTML.
XPath 1.0, which is what browsers implement. XPath 2.0/3.1 functions such as matches() or string-join() are not available.
No. Parsing and evaluation are done by your browser and nothing is uploaded.