DOMXpath – Get href attribute and text value of an a element

Fetch

//td[@class="name"]/a

and then pluck the text with nodeValue and the attribute with getAttribute('href').

Apart from that, you can combine Xpath queries with the Union Operator | so you can use

//td[@class="name"]/a/@href|//td[@class="name"]

as well.

Leave a Comment