Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Xpath nth node

Could someone please tell me what syntax to get to the nth node in the XPath from the google's map api response.

I have tried using the "", "(n)", "{n}", and ":n" in place of the [4thnode here] from the below code section.

And I've searched for hours and nothing come up.

Assuming I have a ZipCode Table created before this.

FOR i = 1 TO 5

     

    LET vCode = peek('ZipCode', $(i)-1, 'ZipCode');

      GeoCodes:

    LOAD

          '$(vCode)' AS PostalCode,

        [result/address_component[4thnode here]/long_name] as StateName,

          [result/geometry/location/lat] AS Latitude,

          [result/geometry/location/lng] AS Longitude

    FROM [http://maps.googleapis.com/maps/api/geocode/xml?address=$(vCode)+USA] (XmlSimple, Table is [GeocodeResponse]);

NEXT

the highlighted line of code I want to get the 4th "address_component" node from the xml path in the attached xml file.

Thank you,

1 Reply
andrewpettit
Partner - Creator
Partner - Creator

I believe the correct XPath syntax is [result/address_component[type="administrative_area_level_1"]/long_name] however I cannot seem to get this to work in Qlik. You might first need to switch from XmlSimple to XmlSax but I am not sure.