XPath exercises

In this part, we are going to focus on hands-on exercises about XPath rules. We will start with matching some XML nodes and attributes on Packt's website. We will use the Google Chrome Developers Tool. 

Let's get started:

  1. Navigate to Packt's web site and open Google Chrome's Developers Tool.
  2. When you open this tool, you will see the following screen:

Google Chrome Developer tools
  1. To write XPath rules, the console should be used, and the XPath rules should be written as shown: $x('//*[@id="menu-books"]') .
  2. If we run this XPath rule, we will get the results shown in the following screenshot:
Elements listed related to the ...

Get R Web Scraping Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.