XML import of nested classes with space between them

138 Views Asked by At

I am using XMLimport to import various bits of information from a coinmarketcap.com page into a Google sheet. It all works perfectly, accept when I come across what look like two classes appearing within a span tag. This is used to show the 24hr Bitcoin price change.

In this case the class is called "sc-15yy2pl-0 gEePkg". But when I try to use this it doesn't work and returns an #N/A instead. This is the code I am trying:

=IMPORTXML("coinmarketcap.com/currencies/bitcoin/", "//span[@class='sc-15yy2pl-0 gEePkg']")

I know their are API's and other things that can do this, but I am not a developer. I am a mere mortal doing my best to learn the IMPORTXML feature. If anyone knows how I should treat these two classes when they have a space between them, I would be most grateful.

1

There are 1 best solutions below

5
Mike Steelson On

With adding https://

=IMPORTXML("https://coinmarketcap.com/currencies/bitcoin/", "//span[@class='sc-15yy2pl-0 gEePkg']")

or

=index(IMPORTXML("https://coinmarketcap.com/currencies/bitcoin/", "//span[@class='sc-15yy2pl-0 gEePkg']"),1,2)

or

=query(IMPORTXML("https://coinmarketcap.com/currencies/bitcoin/", "//span[@class='sc-15yy2pl-0 gEePkg']"),"select Col2,Col4 limit 1 ")

or

=value(textjoin("",,query(IMPORTXML("https://coinmarketcap.com/currencies/bitcoin/", "//span[@class='sc-15yy2pl-0 gEePkg']"),"select Col2,Col4 limit 1 ")))

enter image description here