var td = htmlNode.SelectNodes("td").Select(x => x.InnerText).ToList(); <td align="right"> <img src="templates/images/countmax.png"></td> The td variable contains only elements with the td tag, but I would like the img tag to be seen too.
x.InnerText).ToList();
var td = htmlNode.SelectNodes("td").Select(x => x.InnerText).ToList(); <td align="right"> <img src="templates/images/countmax.png"></td> The td variable contains only elements with the td tag, but I would like the img tag to be seen too.
Your code can be rewritten as:
var tdElements = htmlNode.SelectNodes("td").ToList(); The variable tdElements now contains a list of HtmlNode objects, each of which corresponds to the <td> element and contains all the embedded information. In particular, a child <img> element can be retrieved from the tdElements[0].ChildNodes collection:
var imgElement = tdElements[0].ChildNodes.FindFirst("img"); And you can still extract `InnerText 'from each item:
var innerText = tdElements[0].InnerText; Source: https://ru.stackoverflow.com/questions/476485/
All Articles