-1

ImportXML lets you get information from filetypes such as xml, html, csv, tsv, as well as RSS and Atom feeds.

This example in Google Docs Help for importXml function -

=importXml("toysrus.com";; "//a/@href") 

... fails with this message -

error: The xPath query given could not be evaluated. Please check the syntax of the query: //a/@href

There are 2 other cases where they ran well earlier but now fail. The function scrapes well in this case.

Are there any changes in the way ImportXML function works in Google Docs Spreadsheet that makes it fail in some cases?

  • 1
    Do you still face those problems? Was the answer of @Siva sufficient? Please give us some feedback. – Jacob Jan Tuinstra Jan 20 '13 at 12:47
  • 1
    the reason your syntax didn't work was for a few reasons: you need to have the protocol in front of the url, i.e. http://, you also need only one comma or semicolon between. – Aurielle Perlmann Dec 13 '15 at 5:08
1

error: The xPath query given could not be evaluated. Please check the syntax of the query: //a/@href

The Error message says XPath could not be evaluated.

Here the problem is: you need to provide / target with proper XPath to retrieve the value.

Refer my sample XPath for this:-

=importXml("http://www.toysrus.com", "/html/body/div[@id='hdrWrapper']/div/div/ul/li/a/@href")

UPDATED:

Your requested formula will be as mentioned below:-

=ImportXML("http://www.thefreedictionary.com/p/taciturn", "//div[@class='ds-single']")
| improve this answer | |
  • Thanks, that works but isn't it surprising that the official sample doesn't work – mvark Feb 12 '12 at 6:44
  • Thanks, that works but isn't it surprising that the sample in the official docs doesn't work. Has the syntax changed or are their new rules for it to work? How should I frame the query to get the meaning of a word from thefreedictionary.com. This is what I tried =ImportXML("thefreedictionary.com/p/taciturn","/html/body/div/…) – mvark Feb 12 '12 at 6:51
  • @mvark: I have updated my answer. Refer it. – Siva Charan Feb 12 '12 at 15:18

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.