0

I'm trying to set up an Xpath that will look to see if the last character of the sellingprice attribute ends with a "2". The sellingprice value is between 4-6 characters.

Here's the Xpath I'm currently working with. I'm unable to use ends-with since it's only compatible with 2.0. I've tried to use substrings and string-length, but it isn't working in any iteration I've tried and I can't find any other working examples.

/node[newused[1] != "New" and sellingprice[1][ends-with(.,"2")]]

How can I mimic ends-with functionality for this on 1.0?

2 Answers2

0

I figured out the correct syntax.

using this below gave me the proper result. It only looks to selling price values that end in 2.

/node[newused[1] != "New" and substring(sellingprice[1], string-length(sellingprice[1]) - string-length("2") +1) = "2"]
0

With :

'//version/@sellingprice[ends-with(., 2)]'
Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223
  • Or `//version/@sellingprice[ends-with(., 2)]` so you don't have to repeat `@sellingprice`. Also the OP says "the sellingprice attribute" but based on their xpath they're using "attribute" incorrectly. It's actually a child element. – Daniel Haley Feb 08 '23 at 19:24