Reputation: 41
I have a question about filtering a datafeed with an Xpath.
What I want:
I want to select all the products between 30% en 50% percent discount.
What I’ve already tried after reading this website and didn’t work:
/node[price div price_from from<=.7 to<=.5]
/node[price div price_from from <=.7 to <=.5]
node[price div price_from @from <=.7 and .5 <= @to]
/node[price div price_from from <=”.7” to <=”.5”]
I don’t know what I could try more. Does anyone has a solution for my headache caused problem?
Thank you!
Upvotes: 4
Views: 7982
Reputation: 38444
Assuming XML input like this:
<nodes>
<node>
<price>30</price>
<price_from>60</price_from>
</node>
</nodes>
The following XPath expression will match the nodes that have been discounted anywhere between 30 and 50 percent. It's pretty straightforward, you had the correct idea, just needed to fix the syntax:
//node[(price div price_from >= 0.5) and (price div price_from <= 0.7)]
Upvotes: 3