Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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:
Would really appreciate some help with this one,
thanks!
I found these pages:
http://www.codenameone.com/expression-language-for-json-and-xml.html
But I'm not able to convert the code to work in qlikview...
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