Sample Data
This sheet contains a URL to an XML file and an XPath query to extract all book titles from that XML.
| Cell | Value |
|---|---|
| A1 | URL |
| B1 | XPath Query |
| A2 | https://example.com/sample.xml |
| B2 | //book/title |
Jump into concepts and practice - no test required
This sheet contains a URL to an XML file and an XPath query to extract all book titles from that XML.
| Cell | Value |
|---|---|
| A1 | URL |
| B1 | XPath Query |
| A2 | https://example.com/sample.xml |
| B2 | //book/title |
=IMPORTXML(A2, B2)A B 1 | URL | XPath Query 2 | https://example.com/sample.xml | //book/title
C 1 | Titles 2 | The Great Gatsby 3 | 1984 4 | To Kill a Mockingbird
IMPORTXML function do in Google Sheets?IMPORTXML to get all <h2> elements from a webpage URL in cell A1?=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.=IMPORTXML(A1, "//h2") [OK]=IMPORTXML("https://example.com", "//ul/li"), what will the output be?=IMPORTXML("https://example.com", "//div[@class='price']") but get a #N/A error. What is the likely problem?https://news.example.com where headlines are in <h3 class='headline'> tags. Which formula correctly imports only the text of these headlines?/text() after selecting the element.=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.