简体   繁体   中英

how to use xpath to click the element if the value is greather than?

I have XPath, which click the element when the value matches to 1800, but I want this to work only like if the value is greater than 1800, I am noob and I don't know about that I just googled, Here is working XPath that click on the value 1800, can anyone modify for me,

//uni-view/uni-text/span[contains(text(),"1800")]

If I understand your question correctly, you are looking to only select a span that contains text >1800

Here would be a corresponding sample XML structure,

<uni-view>
  <uni-text>
    <span>
      1750
    </span>
    <span>
      1800
    </span>
    <span>
      1850
    </span>
  </uni-text>
</uni-view>

You are currently using the XPath contains function which will select all span where span/text() contains the given string 1800 . For the given example XML above you will only select the second span because 1800 is contained in the span/text() . If you are looking to select all span where span/text() is '>1800' you can simply remove the XPath contains function and replace it by checking if span/text() > '1800'

//uni-view/uni-text/span[text() > "1800"]

For the given example XML, this will only pull in the third span where span/text() is 1850 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM