user2936461
user2936461

Reputation: 71

xPath - Extracting a contents of a href from an anchor link

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

Answers (1)

alecxe
alecxe

Reputation: 473873

Ask for @href instead of text() and check for the @href attribute to contain mailto:

//a[contains(@href, 'mailto')]/@href

Upvotes: 3

Related Questions