Forum Discussion
Thanks for your patience KarelHusa .. I will need to do some more reading it appears (thanks for the URL you sent) .. I attempted to implement your graceful solution with the count .. but no luck:
count(//ns2:BuyTotal/ns2:Amount[text() = 742.50]) > 0But to no avail .. the below is what I am using to match a 'single' amount record that is being returned .. but I can't get it to 'count' up all the records and find if > 0 of them = 742.50
${FastSearchPackage#Response#declare namespace ns2='http://www.xyz.com/gateway/fire/schema'; //ns2:SearchResponse[1]/ns2:Response[1]/ns2:Suppliers[1]/ns2:Supplier[1]/ns2:Products[1]/ns2:Product[1]/ns2:Rates[1]/ns2:RateTotals[1]/ns2:BuyTotal[1]/ns2:Amount[1]}
I get a 1 for 1 match .. i tried adding count blah blah but could not land the correct answer!!
I did also try with an 'Count' xpatj expression
declare namespace ns2='http://www.xyz.com/gateway/fire/schema';
${FastSearchPackage#Response#declare namespace ns2='http://www.xyz.com/gateway/fire/schema'; //ns2:SearchResponse[1]/ns2:Response[1]/ns2:Suppliers[1]/ns2:Supplier[1]/ns2:Products[1]/ns2:Product[1]/ns2:Rates[1]/ns2:RateTotals[1]/count(ns2:BuyTotal[1]/ns2:Amount[text()=742.50])>0}
But no joy.
relying on a fixed position (using indexes in your XPath) in XML may be fragile. Next time you may get additional elements, and your XPath will no longer work.
That's where a query helps.
What kind of response do you get if you test the following expressions:
//ns2:BuyTotal/ns2:Amount[text() = 742.50]
count(//ns2:BuyTotal/ns2:Amount[text() = 742.50]) > 0