Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

For questions specifically about the Google Sheets function: IMPORTXML()

Use this tag if your question is specifically about using IMPORTXML() in Google Sheets.

From the Google Support page for IMPORTXML:

IMPORTXML

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

Sample Usage

IMPORTXML("https://en.wikipedia.org/wiki/Moon_landing", "//a/@href")

IMPORTXML(A2,B2)

Syntax

IMPORTXML(url, xpath_query)

  • url - 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_query - The XPath query to run on the structured data.

Most of the questions about IMPORTXML fall in at least one of the following categories:

  • The source code of page to examine doesn't follow the XML markup rules

    • Usually the answer is the xPath query of the topmost node that could be retrieved by IMPORTXML then suggest the use of other spreadsheet functions to get the required content.
    • Before posting your question use the W3C Markup Validation Service to check if the page to examine use valid markup.
  • The source code of page to examine doesn't contain the content to be parsed

    • The answer is that Google Sheets built-in functions aren't able to get that content.
    • The above could be because the content isn't included on the publicly available source code of the page
    • If you are planning to ask for tools recommendations to use instead of Google Sheets and IMPORTXML consider to post your question on Software Recommendations
  • The source code of page to examine follow the XML markup rules but the OP has problems to figure out the XPath query

    • IMPORTXML supports XPath 1.0
    • The answers could include a working XPath query.
    • A common issue is due to quote enclosed text ("text") on the xPath query. Use apostrophes to enclose text instead ('text').
  • The issue isn't related to the page to examine

XPath

Tag wikis on other Stack Exchange sites

Related:

history | excerpt history