XPath Tester

Run XPath queries on HTML or XML and list matching elements, attributes and text.

Runs instantly in your browser — results update as you type.

How do I test an XPath expression?

Paste the HTML or XML, type the XPath and the results appear instantly — matching elements, attributes or text nodes, or a number, string or boolean for functions like count(//a). It uses your browser’s native XPath engine.

Common XPath

XPathSelects
//a/@hrefAll link URLs
//h2/text()Text of every H2
//div[@class="price"]Divs with that exact class
//li[contains(., "Sale")]List items containing “Sale”
count(//img)Number of images

Frequently asked questions

Which XPath version?

XPath 1.0, the version built into all browsers and most scraping libraries.

Why does my XML query return nothing?

Elements in a default namespace need a prefix; use local-name(), e.g. //*[local-name()="item"].

Is the document uploaded?

No.