Home > OS >  How to get two columns of data (facility and city) from an online database?
How to get two columns of data (facility and city) from an online database?

Time:09-22

I'm new to XPath and having trouble retrieving the Facility and City data from a table. My intention is to get the four facility names and their cities from the bottom left table on this enter image description here

CodePudding user response:

With xpath 1.0, you can probably only do something like this:

Assuming your url is in A1, enter in B1

=IMPORTXML(A1,"//div[@id='list-facilities']//div[@class='row item']//div[@class='facility']")

and in B2

=IMPORTXML(A1,"//div[@id='list-facilities']//div[@class='row item']//div[@class='city']")

You should get

Cogeco Peer 1 Vancouver 21 North        Vancouver
Cologix VAN2                    Vancouver
Cologix VAN3                     Vancouver
Harbour Centre Vancouver        Vancouver

which is close to what I think you are after.

  • Related