1

I need to create an xpath query that looks for books that have a feedback rating of 98%+ but Amazon returns an estimated feedback so instead of returning the string '98' it returns '98-100%'

is there an easy way to extract the first number from '98-100%' string so that I can run comparisons using xpath?

Below is the current query I am using.

foreach($xml->xpath("//c:LowestOfferListing[./c:Qualifiers/c:SellerPositiveFeedbackRating = '98-100%']") as $listing) print_r($listing)

Ideally I want something such as:

foreach($xml->xpath("//c:LowestOfferListing[./c:Qualifiers/c:SellerPositiveFeedbackRating > 98]") as $listing) print_r($listing);
mk_89
  • 2,692
  • 7
  • 44
  • 62
  • 1
    A related chunk of XML can be found in [this question](http://stackoverflow.com/q/29877169/367456). – hakre Apr 27 '15 at 05:20

1 Answers1

2

Assuming that feedback rating always in the form of range containing - as separator, you can try this xpath (formatted for readability) :

//c:LowestOfferListing[
        ./c:Qualifiers
         /c:SellerPositiveFeedbackRating[
                substring-before(., '-') >= 98
        ]
]

For reference :

har07
  • 88,338
  • 12
  • 84
  • 137