I'm following the accepted answer from this question: How to obtain href values from a div using xpath?
The answer claims the XPath query being used gets the href values from the links but this doesn't seem to be the case with my code. To clarify, this is the accepted answer:
//div[@class="widget-content"]//a/@href
My XPath is as follows:
//tr/td//a/@href
This only seems to select the links, rather than the href values.
So in this case, I then have to use a foreach loop to select the href values.
foreach(var link in links)
{
var hrefValue= link.Attributes["href"].Value;
}
First question, why does this happen? Second question, is there a way to directly get the href values?
For further context. I'm trying to select all href values from inside a HTML table.
EDIT: Example of HTML I'm trying to parse: http://www.realtimetrains.co.uk/train/W90778/2019/04/29/advanced