Google Spreadsheet Importxml Error: Imported Xml Content Cannot Be Parsed

This function seems to work in general, but in this case:

URL:

XPATH: //*[@id='leftTable']/table[1]/tbody/tr[23]/td[2] (although it doesn't work with any XPATH).

I get the error

Error: Imported XML content cannot be parsed.

I think the problem is with the page itself, but I cannot see what Google is seeing (or can I?) Any pointers would be much appreciated.

4

2 Answers

Incredibly odd, but the general solution for problems regarding the IMPORTXML function in the new version of Google Sheets is - use the older version.

There, if the following formula is used in a cell:

=IMPORTXML("","//*[@id='leftTable']/table[1]/tbody/tr[23]/td[2]")

The displayed result is:

8.10p

Which is correct, I assume.

4

Most ImportXML errors today are because the page is using Javascript.

If you use Developer Tools and inspect the site in Chrome, you find the HTML which was rendered into the DOM by the Javascript. BUT if you look at the the page source, you won't find the data.

Google Sheets doesn't act as a client browser so there is nowhere for the JS to execute.

This is why the copied XML path from Inspect Element into Google Sheets IMPORTXML errors out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest