How can I find the link URL by link text with XPath?

后端 未结 6 1842
臣服心动
臣服心动 2020-12-04 08:06

I have a well formed XHTML page. I want to find the destination URL of a link when I have the text that is linked.

Example



        
6条回答
  •  感动是毒
    2020-12-04 08:19

    For case insensitive contains, use the following:

    //a[contains(translate(text(),'PROGRAMMING','programming'), 'programming')]/@href
    

    translate converts capital letters in PROGRAMMING to lower case programming.

提交回复
热议问题