Reputation: 71
I am having difficulty extracting the contents of a href from an anchor tag with xPaths. I want to extract the contents of the href only, not the text contained within the anchor elements.
This is what I've come up with so far but it doesn't seem to be working.
//a/@href[contains("@", 'mailto')]/text()
I also tried:
//a/href[contains("@", 'mailto')]/text()
Anyone have any suggestions, greatly appreciated!
Upvotes: 1
Views: 1226
Reputation: 473873
Ask for @href
instead of text()
and check for the @href
attribute to contain mailto
:
//a[contains(@href, 'mailto')]/@href
Upvotes: 3