XPath to get another attribute by id attribute
70,870
Try this XPath: //a[@id = 'unique-id']/@href
. This XPath will select href
attribute of a
element with attribute id
= unique-id
Author by
user151841
Updated on July 09, 2022Comments
-
user151841 almost 2 years
I am using XPath to pull data off of a web page.
I have a link that I want to get the href value of. I can reference it through its unique id:
id('unique-id')
, but that gives me the string between the<a>
tags.How do I get the value of the
href
attribute?