Reputation: 169
My code looks like this:
var matchTableHtml =
loginPage.DocumentNode
.SelectNodes("//table[@id='uc_refereeMatchProgram_dgMatchCategory1']
//tr[@class!='DataGridHeaderStyle']");
This returns a collection of nodes - as intended, so no problem in that - but!!!
var testing = matchTableHtml.Descendants()
.Select(x => new Match()
{
Row = x.SelectSingleNode("//td/a[position()=1]")
.InnerText
});
Here 'x' returns the node from the documentNode and not from the 'matchTableHtml.Descendants'-collection. Anybody who knows why?
Upvotes: 2
Views: 1033
Reputation: 169
Ok - the solution was very simple... I was not starting from 'current node' but the XPath starting with // is of course relative to the root node.
Simple solution - add a dot - which gives denotes that we start from current ('//' ==> './/'):
Row = x.SelectSingleNode(".//td/a[position()=1]")
.InnerText
Upvotes: 2