Selecting elements whose attribute begins with something in XPath

前端 未结 2 1491
走了就别回头了
走了就别回头了 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: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/')]")

提交回复
热议问题