XPath to get another attribute by id attribute

XmlXsltXpath

Xml Problem Overview


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?

Xml Solutions


Solution 1 - Xml

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser151841View Question on Stackoverflow
Solution 1 - XmlKirill PolishchukView Answer on Stackoverflow