Xpath, range between two values, how?

I have a question about filtering data using Xpath. What I want: I want to select all products with 30% discount up to 50%. What I've already tried after reading this site 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. Anyone have a solution to the problem my headache caused?

Thank!

+3


source to share


1 answer


Assuming XML input like this:

<nodes>
    <node>
        <price>30</price>
        <price_from>60</price_from>
    </node>
</nodes>

      



The following XPath expression will match nodes that have been discounted between 30 and 50 percent. It's pretty simple, you had the right idea, just to fix the syntax:

//node[(price div price_from >= 0.5) and (price div price_from <= 0.7)]

      

+2


source







All Articles