2

I was trying to get few details from a link on google spreadsheet.

Link: http://www.justdial.com/Gurgaon/Travel-Agents/ct-302

I want to extract all the four lines i.e. name, phone no, address and category of each block.

I ran the following query to extract the name but it was not working.

importxml(url, "//span[@class='jcn']/a")

Error = "imported xml content cannot be parsed"

Please help.

user3616725
  • 3,485
  • 1
  • 18
  • 27
user3398251
  • 33
  • 1
  • 3
  • 6
  • what do you mean by " it was not working" - are you getting an error? if I use your formula I get a list of 25 names just fine... – user3616725 Oct 15 '14 at 14:28
  • Error = "imported xml content cannot be parsed" https://docs.google.com/a/casa2inns.com/spreadsheets/d/1_X1YPTDn_I6Y3lQ6JLllIrGF91cH2yBnxa5hkhsDa1g/edit#gid=0 – user3398251 Oct 16 '14 at 06:19
  • which cell do you store the url in? What does your importXML formula look like EXACTLY? – user3616725 Oct 16 '14 at 07:17
  • please go to the google doc link. i have put the url in a2 and formula in b2 – user3398251 Oct 16 '14 at 08:13

1 Answers1

3

EDIT: Please note, that as of 18/06/2015 this error no longer appears in New Sheets! Looks like google fixed it! ;)


ORIGINAL ANSWER:

This has proved to be an interesting one...
I cannot explain why - the odd bahaviours in google sheets have baffled me for a while...

I have tested this, and your IMPORTXML() formula returns en error, as described by you on google sheets using the "New Google Sheets", but not on sheets that have been created using the "old sheets"

How to tell if a sheet is "old" or "new":

New sheets have (when opened)

  • a green tick on the bottom of the screen
  • a green "sheet" icon on the tab / window title bar (favicon)
  • a "Add-ons" menu item on the main toolbar between "Tools" and "Help"

Old sheets have (when opened)

  • no tick
  • a 3-coloured "drive" triangle icon on the tab / window title bar (favicon)
  • no "Add-ons" menu item

How do you create an Old-Sheet? - Click g.co/oldsheets (here is the original google help article)

Once you've done that, write your IMPORTXML() function exactly as you described

user3616725
  • 3,485
  • 1
  • 18
  • 27
  • it worked..thanks :) [Very odd behaviour] i cannot vote up as i do not have much credits/reputation. sorry :p – user3398251 Oct 16 '14 at 10:33
  • @krushnach Chandra both this question and its answer are now over 6 years old, and "old" google sheets have been totally retired. So NO, i cannot show you a working solution XD – user3616725 Apr 15 '21 at 12:38