Skip to content
scraper.tools

XPath tester: evaluate XPath 1.0 on real HTML

Evaluate XPath 1.0 expressions against a live page or pasted HTML. Node sets, strings, numbers and booleans are all shown, with export to CSV, Excel and JSON.

Showing a sample page so you can try things straight away. Fetch a URL or paste HTML to use your own.
Language
Try on the sample:

0 matches

Loading…

How to use it

  1. 1

    Load a page by URL or paste HTML. A sample document is loaded to start with.

  2. 2

    Type an expression such as //h2/a/@href. Results update as you type.

  3. 3

    Export the matches, or copy the expression into your scraper.

Questions

Which XPath version is this?
XPath 1.0, evaluated by your browser's document.evaluate. That is the version supported by browsers, lxml, Scrapy and most scraping libraries. XPath 2.0 functions such as matches() or lower-case() are not available.
How do I match an element by its class?
Use contains(concat(" ", normalize-space(@class), " "), " price ") to match a class token exactly. A plain contains(@class, "price") also matches "price-old".
Why do I get results for count() but not a list?
Functions like count(), string() and boolean() return a single value instead of nodes. The tester shows that value and its type.

Guides

Related tools

Need the same data every day, or from many pages? Build a scraper by clicking what you want, then schedule it.