Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Reverse geocoding, how to select a specific part of the xml

Hello!

I'm trying to get the address and county for my longitude and latitude values. It works fine to get the connection to Google reverse geocode to work and I can extract the "formatted_address" as the address. But there are a lot of address components, and I only want to extract the one labeled 'political'.

So what I want to do is get the value of result/address_component/long_name, but only if the corresponding result/address_component/type = 'political'.

My code:

let noRows = NoOfRows('SiteID_SiteName')-1;

for i=0 to $(noRows)

          let d=peek('latitude2',$(i),'SiteID_SiteName');

          let p=peek('longitude2',$(i),'SiteID_SiteName');

 

  LatLngLan:

          LOAD

          [result/formatted_address] as Address,

[result/address_component(type='political')/long_name] as County                <--- what to do here?

 

          FROM [http://maps.google.com/maps/api/geocode/xml?latlng=$(d),$(p)&oe=utf8&sensor=false] (XmlSimple, Table is [GeocodeResponse]);

 

  next

Example xml:

http://maps.google.com/maps/api/geocode/xml?latlng=55.381304614645,13.271566697822&oe=utf8&sensor=fa...

Would really appreciate some help with this one,

thanks!

2 Replies
Not applicable
Author

Not applicable
Author

Hi rigul123,

You could do this way...

let noRows = NoOfRows('SiteID_SiteName')-1;

for i=0 to $(noRows)

          let d=peek('latitude2',$(i),'SiteID_SiteName');

          let p=peek('longitude2',$(i),'SiteID_SiteName');

  LatLngLan:

          LOAD

          [result/formatted_address] as Address,

          [result/address_component/long_name] as County

          FROM [http://maps.google.com/maps/api/geocode/xml?latlng=$(d),$(p)&oe=utf8&sensor=false] (XmlSimple, Table is [GeocodeResponse])

where [result/formatted_address/type] = 'political';

  next