XPath to get another attribute by id attribute

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?


Try this XPath: //a[@id = 'unique-id']/@href. This XPath will select href attribute of a element with attribute id = unique-id