Complete the formula to import all the links from a webpage using IMPORTXML.
=IMPORTXML("https://example.com", "[1]")
The XPath //a/@href selects all link URLs from anchor tags on the page.
Complete the formula to import all the titles inside <title> tags from a webpage.
=IMPORTXML("https://example.com", "[1]")
The XPath //title selects all
Fix the error in the formula to import all paragraph texts from a webpage.
=IMPORTXML("https://example.com", [1])
The XPath //p/text() selects the text nodes inside all paragraph tags, which IMPORTXML can import as text.
Fill both blanks to import all image URLs and all link URLs from a webpage.
=IMPORTXML("https://example.com", "[1] | [2]")
The XPath //img/@src selects all image URLs, and //a/@href selects all link URLs. Using the pipe | combines both selections.
Fill all three blanks to import all product names, prices, and availability from a webpage with structured HTML.
=IMPORTXML("https://example.com/products", "//div[@class='product']/[1] | //div[@class='product']/[2] | //div[@class='product']/[3]")
Each XPath selects a specific span inside the product div: name, price, and availability. Combining them with | imports all three data types.
Practice
IMPORTXML function do in Google Sheets?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 AQuick Check:
IMPORTXML = fetch web data [OK]
- Thinking IMPORTXML only works with other sheets
- Confusing IMPORTXML with chart creation
- Assuming it exports data instead of importing
IMPORTXML to get all <h2> elements from a webpage URL in cell A1?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.Final Answer:
=IMPORTXML(A1, "//h2") -> Option DQuick Check:
Correct XPath syntax ==IMPORTXML(A1, "//h2")[OK]
- Adding brackets [] incorrectly in XPath
- Omitting // in XPath
- Trying to get text as attribute with @text
=IMPORTXML("https://example.com", "//ul/li"), what will the output be?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 CQuick Check:
XPath selects all matching nodes = All list items (- ) inside unordered lists (<ul>) from the page. [OK]
- Assuming only first match is returned
- Confusing <li> with <p> tags
- Thinking XPath syntax is wrong here
=IMPORTXML("https://example.com", "//div[@class='price']") but get a #N/A error. What is the likely problem?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 AQuick Check:
#N/A often means URL problem [OK]
- Assuming XPath syntax is wrong when it's correct
- Not verifying the URL is accessible
- Thinking IMPORTXML can't filter by attributes
https://news.example.com where headlines are in <h3 class='headline'> tags. Which formula correctly imports only the text of these headlines?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 BQuick Check:
Use /text() to get element text [OK]
- Omitting /text() and getting full HTML tags
- Using @text which is not an attribute
- Trying invalid XPath like innerText
