Arvind
Arvind

Reputation: 2781

xpath for price with currency

<category>
    <Movi Name="Test">
        <Price>$3.95</Price>
    </Movi>
    <Movi Name="test d">
        <Price>$13.95</Price>
    </Movi>
</category>

can anyone help on this XML to find movie greater than $11 with XPath

Upvotes: 1

Views: 378

Answers (2)

Jack Fleeting
Jack Fleeting

Reputation: 24928

Just for the sake of completeness, another option is:

//Price[number(translate(text(), '$','')) > 11]

Upvotes: 0

igneus
igneus

Reputation: 1012

Given all prices are in the same currency and format, this bit of XPath does the job:

/category/Movi[number(substring(./Price/text(), 2)) > 11]

Upvotes: 2

Related Questions