Search code examples
xmlxpathtemenos-quantum

Cannot retrieve xml attributes in kony


I am parsing a web-service in kony and it gives me the result in the following format:

 <?xml-stylesheet href="/v1/xsl/xml_pretty_printer.xsl" type="text/xsl"?><products canonicalUrl="/v1/products(search=&quot;hdmi&quot;)?apiKey=przdaw9nuqfefhavq3ud4tfh" currentPage="1" from="1" partial="false" queryTime="0.005" to="10" total="2241" totalPages="225" totalTime="0.087">
       <product>
          .....
          .....
       </product>
       <product>
          .....
          .....
       </product>
       <product>
          .....
          .....
       </product>
       <product>
          .....
          .....
       </product>
    </products>

I configured the output parameter as giving the root of Xpath as //products and to fetch a particular item from product say name,I used product/name.The response is coming perfectly.

Now I want to fetch root level elements such as currentPage="1" and totalPages="225" for the purpose of pagination and I cannot do that.

What I have done:enter image description here

But unfortunately,in this way I cannot access the currentPage attribute.

Please help.


Solution

  • Judging from your screenshot you apparently try to do

    //products[/currentPage]
    

    This is is best described as a shot in the dark in the hopes to hit something. Please take a few moments to learn about the basics of XPath and about the structure of the DOM.

    /products/@currentPage
    

    (Alternatively just @currentPage in the collection pdetails, which amounts to the same thing.)