Selecting elements whose attribute begins with something in XPath

前端 未结 2 1489
走了就别回头了
走了就别回头了 2020-12-07 16:30

As the title says, is it possible to select elements in XPath that only begin with a certain string, but perhaps do not end with the same?

For example there are 3 an

相关标签:
2条回答
  • 2020-12-07 16:53

    //a[starts-with(@href, 'buy.php/')]

    http://www.zvon.org/xxl/XSLTreference/Output/function_starts-with.html

    0 讨论(0)
  • 2020-12-07 16:56

    Not sure if this is exactly the correct syntax but you probably want to use the fn:contains xpath function. Other useful functions you can find here:

    http://www.w3schools.com/xpath/xpath_functions.asp#string

    getByXPath("//a[fn:contains(@href/text(), 'buy.php/')]")

    0 讨论(0)
提交回复
热议问题