1 Reply Latest reply: Jun 19, 2017 1:05 PM by Andrew Pettit RSS

    Xpath nth node

    Kim Nguyen

      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)", "{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');



                '$(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]);




      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,

        • Re: Xpath nth node
          Andrew Pettit

          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.