Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What does the IMPORTXML function do in Google Sheets?
IMPORTXML fetches data from a web page by extracting structured data using XPath queries. It helps you pull specific parts of a webpage like tables, lists, or links directly into your sheet.
Click to reveal answer
beginner
What are the two main arguments of IMPORTXML?
The first argument is the URL of the webpage you want to get data from. The second argument is the XPath query that tells Google Sheets which part of the page to extract.
Click to reveal answer
intermediate
Example XPath query to get all links (<a> tags) from a webpage?
Use the XPath query //a/@href. This selects the href attribute of all anchor tags, which are the links on the page.
Click to reveal answer
intermediate
Why might IMPORTXML return an error or no data?
Common reasons include: the URL is incorrect or blocked, the XPath query is wrong or too specific, or the webpage uses JavaScript to load data dynamically which IMPORTXML can't read.
Click to reveal answer
intermediate
How can you find the correct XPath for data you want to import?
Use your browser's Developer Tools to inspect the webpage elements. Right-click the element, choose 'Inspect', then right-click the highlighted code and select 'Copy XPath' or write a simple XPath based on the HTML structure.
Click to reveal answer
What is the correct syntax to import all paragraph texts from a webpage using IMPORTXML?
AIMPORTXML("url", "//p")
BIMPORTXML("url", "//div")
CIMPORTXML("url", "//a/@href")
DIMPORTXML("url", "//table")
✗ Incorrect
The XPath //p selects all paragraph elements, so IMPORTXML("url", "//p") imports all paragraphs.
Which of these is NOT a valid reason for IMPORTXML to fail?
AThe XPath query is incorrect
BThe spreadsheet has too many rows
CThe URL is misspelled
DThe webpage uses JavaScript to load data dynamically
✗ Incorrect
IMPORTXML failure is usually due to URL, XPath, or dynamic content issues, not the number of rows in the sheet.
The first argument of IMPORTXML is the URL string of the webpage.
Which tool helps you find XPath queries easily?
AGoogle Translate
BSpreadsheet formula bar
CBrowser Developer Tools
DText editor
✗ Incorrect
Browser Developer Tools let you inspect webpage elements and copy XPath queries.
Explain how to use IMPORTXML to get a list of all links from a webpage into Google Sheets.
Think about what part of the webpage holds links and how to write XPath for it.
You got /4 concepts.
Describe common reasons why IMPORTXML might not return data and how to troubleshoot them.
Consider what IMPORTXML can and cannot read from webpages.
You got /5 concepts.
Practice
(1/5)
1. What does the IMPORTXML function do in Google Sheets?
easy
A. It fetches data from a web page using a URL and XPath query.
B. It imports data from another Google Sheet only.
C. It creates charts based on web data automatically.
D. It exports your sheet data to a web page.
Solution
Step 1: Understand IMPORTXML purpose
IMPORTXML is designed to pull data from web pages by using a URL and an XPath query to specify what data to extract.
Step 2: Compare options
Only "It fetches data from a web page using a URL and XPath query." correctly describes this function. The other options describe unrelated features.
Final Answer:
It fetches data from a web page using a URL and XPath query. -> Option A
Quick Check:
IMPORTXML = fetch web data [OK]
Hint: IMPORTXML grabs web data using URL + XPath [OK]
Common Mistakes:
Thinking IMPORTXML only works with other sheets
Confusing IMPORTXML with chart creation
Assuming it exports data instead of importing
2. Which of these is the correct syntax for using IMPORTXML to get all <h2> elements from a webpage URL in cell A1?
easy
A. =IMPORTXML(A1, "//h2/@text")
B. =IMPORTXML(A1, "//h2[]")
C. =IMPORTXML(A1, "h2")
D. =IMPORTXML(A1, "//h2")
Solution
Step 1: Recall IMPORTXML syntax
The function takes two arguments: a URL and an XPath query. To select all <h2> elements, the XPath is "//h2".
Step 2: Evaluate options
=IMPORTXML(A1, "//h2") uses correct XPath syntax. =IMPORTXML(A1, "//h2[]") has invalid brackets. =IMPORTXML(A1, "h2") misses the XPath axis. =IMPORTXML(A1, "//h2/@text") tries to get an attribute "text" which doesn't exist.
Hint: Use double slashes and tag name for XPath [OK]
Common Mistakes:
Adding brackets [] incorrectly in XPath
Omitting // in XPath
Trying to get text as attribute with @text
3. Given the formula =IMPORTXML("https://example.com", "//ul/li"), what will the output be?
medium
A. All paragraphs (<p>) from the page.
B. Only the first list item from the page.
C. All list items (<li>) inside unordered lists (<ul>) from the page.
D. An error because XPath is invalid.
Solution
Step 1: Understand the XPath query
The XPath "//ul/li" selects all
elements that are children of any <ul> element on the page.
Step 2: Predict IMPORTXML output
IMPORTXML will return all matching list items, not just the first, and it won't return paragraphs or error since XPath is valid.
Final Answer:
All list items (
) inside unordered lists (<ul>) from the page.
-> Option C
Quick Check:
XPath selects all matching nodes = All list items (
) inside unordered lists (<ul>) from the page. [OK]
Hint: XPath //ul/li selects all list items under ul [OK]
Common Mistakes:
Assuming only first match is returned
Confusing <li> with <p> tags
Thinking XPath syntax is wrong here
4. You wrote =IMPORTXML("https://example.com", "//div[@class='price']") but get a #N/A error. What is the likely problem?
medium
A. The URL is invalid or unreachable.
B. The XPath syntax for class attribute is incorrect.
C. IMPORTXML does not support attribute filters.
D. You must use single quotes inside the XPath instead of double quotes.
Solution
Step 1: Check XPath syntax
The XPath "//div[@class='price']" is correct for selecting divs with class 'price'.
Step 2: Consider other causes of #N/A
#N/A often means the URL is unreachable or blocked. IMPORTXML supports attribute filters and double quotes inside XPath strings are allowed if escaped properly.
Final Answer:
The URL is invalid or unreachable. -> Option A
Quick Check:
#N/A often means URL problem [OK]
Hint: Check URL accessibility if #N/A error occurs [OK]
Common Mistakes:
Assuming XPath syntax is wrong when it's correct
Not verifying the URL is accessible
Thinking IMPORTXML can't filter by attributes
5. You want to import the latest news headlines from https://news.example.com where headlines are in <h3 class='headline'> tags. Which formula correctly imports only the text of these headlines?
hard
A. =IMPORTXML("https://news.example.com", "//h3[@class='headline']")
B. =IMPORTXML("https://news.example.com", "//h3[@class='headline']/text()")
C. =IMPORTXML("https://news.example.com", "//h3[@class='headline']/@text")
D. =IMPORTXML("https://news.example.com", "//h3[@class='headline']/innerText")
Solution
Step 1: Understand XPath to get text content
To get only the text inside elements, use the XPath function /text() after selecting the element.
Step 2: Evaluate options
=IMPORTXML("https://news.example.com", "//h3[@class='headline']/text()") correctly uses /text(). =IMPORTXML("https://news.example.com", "//h3[@class='headline']") returns the whole element including tags. =IMPORTXML("https://news.example.com", "//h3[@class='headline']/@text") tries to get an attribute 'text' which doesn't exist. =IMPORTXML("https://news.example.com", "//h3[@class='headline']/innerText") uses invalid XPath syntax.
Final Answer:
=IMPORTXML("https://news.example.com", "//h3[@class='headline']/text()") -> Option B
Quick Check:
Use /text() to get element text [OK]
Hint: Add /text() to XPath to get only text content [OK]