XPath Tester
Run an XPath 1.0 expression against XML or HTML and see every matching node, attribute or the number, string or boolean it returns.
Free · No sign-up · Your inputs stay in your browser
Input
Test an XPath expression
Output
0 nodes
Evaluated by the browser's own XPath 1.0 engine, the version libxml2 (PHP's DOMXPath, lxml) and Selenium use. XPath 2.0 functions such as matches() and lower-case() are not part of it. Namespaced documents need a prefix mapping, which this does not set up.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
Expressions worth knowing
//book[price > 30]/title filters by a child's value, //a[contains(@href, 'github')] matches on part of an attribute, //title[contains(., 'MySQL')]/.. walks up to the parent, and //tr[td[1] = 'Total']/td[2] reads a table cell by its row label. The XPath 1.0 recommendation defines the functions available.
Namespaces
A document with a default namespace, such as XHTML, an RSS feed with extensions or a SOAP envelope, does not match unprefixed names, which is the usual reason an expression that looks right returns nothing. In code, register a prefix (DOMXPath::registerNamespace in PHP) or match with local-name().