How to use IMPORTXML in Google Sheets

IMPORTXML is a useful data manipulation function in Google Sheets. Here's how to use IMPORTXML to automate data entry in Google Sheets.

What is IMPORTXML in Google Sheets?

The formula of the IMPORTXML function in Google Sheets is as follows:

=IMPORTXML(url, xpath_query)

The IMPORTXML function imports data from any of the different structured data types, including XML, HTML, CSV, TSV, RSS, and ATOM XML.

It pulls information from every XML field. You can use it to enter publicly available information on the Internet. Therefore, you are not allowed to use it with the web, which must be logged in to access.

When to use IMPORTXML in Google Sheets?

  1. Extract data from the web
  2. When you need data on the page but can't activate Screaming Frog

How to use IMPORTXML in Google Sheets

Before diving into the actual usage of IMPORTXML, you need to understand the arguments in the formula:

How to use IMPORTXML in Google Sheets Picture 1How to use IMPORTXML in Google Sheets Picture 1

URL

  1. Is the URL of the website you want to import data from.
  2. Include protocol (https:// or http://).
  3. Must include the value of the URL in quotation marks or refer to a cell containing the appropriate text.

XPath Query

  1. The XPath query runs on the provided URL's data.
  2. Each result from the XPath query is placed in its own row of the worksheet.
  3. XPath is a query language used to retrieve pieces of information on the web.
  4. It has its own syntax that you can learn in detail from online sources.

 

Things to know about XPath:

  1. Data on the web is displayed and saved in XML format.
  2. Data query language.
  3. It is possible to customize the Xpath arguments according to what you are looking for in the web.

The IMPORTXML function allows you to import data directly from the web into a spreadsheet. You just need to look at the web source code at the location where you want to import the data, find the usable HTML element, and extract it using XPath queries.

To find the HTML element, you have to look at the web page code. For example, to a wiki page, right-click the page and click View page source in the menu that appears. When the site is open source, you will see its HTML code. For example, on the Wikipedia web:

How to use IMPORTXML in Google Sheets Picture 2How to use IMPORTXML in Google Sheets Picture 2

Maybe you are familiar with HTML tabs like

,

, … You need to use these tags in xpath_query to import the desired data from the web.

Example of using IMPORTXML in Google Sheets:

How to use IMPORTXML in Google Sheets Picture 3How to use IMPORTXML in Google Sheets Picture 3

 

How to use IMPORTXML in Google Sheets Picture 4How to use IMPORTXML in Google Sheets Picture 4 How to use IMPORTXML in Google Sheets Picture 5How to use IMPORTXML in Google Sheets Picture 5

Here's what you need to know about using IMPORTXML in Google Sheets . Hope the article is useful to you.

4 ★ | 8 Vote