Sign up ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

I've used this query to calculate distance between two locations, now it won't work anymore, and returns the error xPath query didn't get any result (translated from Italian, I don't know if is the same in English).

This is the query:

=INT(SUBSTITUTE(INDEX(importXML(""&SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE( C5 ;CHAR(13);" ");CHAR(10);" ")); " "; "+")&"&daddr="&SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE( E16 ;CHAR(13);" ");CHAR(10);" ")); " "; "+")&"&ie=UTF8&hl=it&output=mobile&f=d&btnG=Get+Directions" ; "//span[1]" ) ; 1);" km";""))

what's the problem? Should I update this method because it's deprecated?

share|improve this question
some importXML samples that I tried didn't work either. In fact, the example in their Help fails too: =importXml("";; "//a/@href") - – mvark Feb 11 '12 at 18:01

1 Answer 1

Getting data by parsing the HTML source of a page is a fragile method: when the pages gets redesign, the import is most likely going to break down because the data you want are not where you expect. It's no coincidence that most of examples on Google's own IMPORTXML documentation page are broken by now.

I recommend using Google Distance Matrix API instead (it is a subset of Google Maps API). It also accepts HTTP requests and can return data as XML; but this XML will have predictable, documented structure for the lifetime of the API version.

Examples of parsing Google's XML response with XPath are found here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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