Check this example :
var html = @"<div>
<b>Downloads (current version):</b> 123 <br />
<b>Downloads (total):</b> 253</td>
<br />
</div>";
var htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(html);
var result = htmlDoc.DocumentNode.SelectNodes("/div/text()[normalize-space(.)]");
foreach (var r in result)
{
Console.WriteLine(r.InnerText.Trim());
}
this part of XPath from above example :
/div/text()
means, select all text nodes those are direct child of <div>
element. And the last part :
[normalize-space(.)]
filters out empty text nodes.
UPDATE :
Responding to your comment, you can try this way instead :
var result =
htmlDoc.DocumentNode
.SelectNodes(@"/div/b[.='Downloads (current version):'
or
.='Downloads (total):']/following-sibling::text()[1]");
Above XPath selects text node that is directly after specific <b>
elements.