ethanenglish
ethanenglish

Reputation: 1327

Less Than XPath

I'm trying to pull products on sale from an xml file. Here is my XML:

<product>
    <programname>​QVC.​com​</programname>
    <programurl>​http​://​www.​qvc.​com​</programurl>
    <catalogname>​QVC Product Catalog​</catalogname>
    <lastupdated>​04/​17/​2013​</lastupdated>
    <name>Product 1</name>
    <keywords>​CTA Digital, Electronics, Video Games, Hardware. Nintendo Wii​</keywords>
    <manufacturer>​CTA Digital​</manufacturer>
    <currency>​USD​</currency>
    <saleprice>​15.​96​</saleprice>
    <price>​17.​96​</price>
    <retailprice>​17.​96​</retailprice>
</product>

I used the following xpath but it didn't work: /product[saleprice < retailprice]. I'm looking for the output to be true for any product where saleprice is less than retail price. Any thoughts on what I might be doing wrong?

Upvotes: 1

Views: 515

Answers (1)

collapsar
collapsar

Reputation: 17238

try

/product[number(saleprice) < number(retailprice)]

Upvotes: 2

Related Questions