选择其属性以XPath中的某些内容开头的元素


86

就像标题中所说的那样,是否可以在XPath中选择仅以特定字符串开头但不以相同字符串结尾的元素?

例如,有3个锚元素:

<a href="buy.php/onething"></a><a href="buy.php/twothing"></a><a href="sell.php/anotherthing"></a>

我只想获取以'buy.php /'开头的锚元素。我认为以下内容不会起作用:

getByXPath("//a[@href='buy.php/']")

我怎样才能做到这一点?

Answers:



By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.