0
0
Google Sheetsspreadsheet~10 mins

IMPORTXML for structured data in Google Sheets - Cell-by-Cell Formula Trace

Choose your learning style9 modes available
Sample Data

This sheet contains a URL to an XML file and an XPath query to extract all book titles from that XML.

CellValue
A1URL
B1XPath Query
A2https://example.com/sample.xml
B2//book/title
Formula Trace
=IMPORTXML(A2, B2)
Step 1: A2
Step 2: B2
Step 3: IMPORTXML("https://example.com/sample.xml", "//book/title")
Cell Reference Map
    A                   B
1 | URL               | XPath Query       
2 | https://example.com/sample.xml | //book/title
The formula references cell A2 for the URL and B2 for the XPath query.
Result
    C
1 | Titles           
2 | The Great Gatsby  
3 | 1984             
4 | To Kill a Mockingbird
The IMPORTXML formula outputs the list of book titles vertically starting from the cell where the formula is entered.
Sheet Trace Quiz - 3 Questions
Test your understanding
What does the XPath query "//book/title" select in the XML?
AAll <title> elements inside <book> elements anywhere in the XML
BOnly the first <title> element in the XML
CAll <book> elements inside <title> elements
DAll elements named 'book/title' as a single tag
Key Result
IMPORTXML(url, xpath_query) fetches XML from the URL and extracts data matching the XPath query as a list.