I have html like:
<div class="asd">
lalala
</br>
lalala2
<div>
aaaaa
</div>
</div>
I need to get only "lalala \n lalala2" without using XPath.
You can create extension method for HtmlNode
public static class HtmlHelper
{
public static string InnerText(this HtmlNode node)
{
var sb = new StringBuilder();
foreach (var x in node.ChildNodes)
{
if (x.NodeType == HtmlNodeType.Text)
sb.Append(x.InnerText);
if (x.NodeType == HtmlNodeType.Element && x.Name == "br")
sb.AppendLine();
}
return sb.ToString();
}
}
just find the node and call node.InnerText()