Common XPath
| XPath | Selects |
|---|---|
//a/@href | All 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.

