Recently, I’m doing web scraping using the awesome library HtmlAgilityPack. With HtmlAgilityPack, I use XPath to match the required object/tag in the DOM. While working with XPath, I’m wondering is there anyway to test XPath in Google Chrome browser with highlighting the matched tag in browser. The answer is YES. We can test XPath in Google Chrome.

Here is the steps to do so:

  1. Open Developer Tools
  2. Select Console tab.
  3. Use $x token. For example, $x("/html/body") will select the body tag.

A picture worth a thousand words. :)

xpath in chrome