Skip to content
Google Sheets

IMPORTXML function in Google Sheets

Imports data from any of various structured data types including XML, HTML, CSV, TSV, and RSS and ATOM XML feeds.

=IMPORTXML(url, xpath_query, locale)

IMPORTXML syntax and parameters

Three arguments, two required.

  • urlstringRequired

    The URL of the page to examine, including protocol (e.g. http://). The value for url must either be enclosed in quotation marks or be a reference to a cell containing the appropriate text.

  • xpath_querystringRequired

    The XPath query to run on the structured data. For more information on XPath, see http://www.w3schools.com/xml/xpath_intro.asp.

  • localestringOptional

    A language and region locale code to use when parsing the data. If unspecified, the document locale is used.

IMPORTXML examples

Formulas you'll actually reuse.

  1. The page's main heading by XPath:

    =IMPORTXML("https://example.com/products/42", "//h1")
  2. Every link on the page, one per row — an attribute selected with @:

    =IMPORTXML("https://example.com/products/42", "//a/@href")

IMPORTXML in Excel

No direct equivalent — here's the way around.

Try IMPORTXML in the playground

Edit the example — nothing to install.

Preloaded with the IMPORTXML formula from Example 1 — change anything and watch it respond.

Loading the editor…

IMPORTXML errors

What they mean — and the fixes.

  • #N/A

    The XPath matched nothing — pages rendered by JavaScript often have no such node in the raw HTML; test the XPath against view-source.