Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XPath to get another attribute by id attribute

Tags:

xml

xslt

xpath

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?

like image 877
user151841 Avatar asked Jul 27 '11 12:07

user151841


1 Answers

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

like image 84
Kirill Polishchuk Avatar answered Oct 08 '22 23:10

Kirill Polishchuk