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.
- For more information on XPath, see http://www.w3schools.com/xml/xpath_intro.asp.
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
- If the question is about a Google Sheets functions and formulas errors include the cell displayed error and the pop-up textual error message.
- If the question is about the automatic refresh of the imported results, before posting your question see What are the refresh characteristics of the Google Spreadsheet Import functions?
XPath
Tag wikis on other Stack Exchange sites
- Stack Overflow -> https://stackoverflow.com/tags/xpath/info
- Very expense content. More than 26k questions
- Super User -> https://superuser.com/tags/xpath/info
- Very scarce content. 7 questions
- Software Engineering -> https://softwareengineering.stackexchange.com/tags/xpath/info
- No guidance / wiki. 4 questions
- Server Fault -> https://serverfault.com/tags/xpath/info
- Wiki content very similar to Stack Overflow. 3 questions
- Software Recommendations -> https://softwarerecs.stackexchange.com/tags/xpath/info
- Very scarce content. 2 questions
Related: