let say i have follow html document
<div class=" wrap_body text_align_left" style="">
<div class="some"> hello </div>
<div class="someother"> world </div>
hello world
</div>
i want to extract this
<div class="some"> hello </div>
<div class="someother"> world </div>
hello world
what is best way to extract using HtmlAgilityPack with c# or vb.net? this is my code until done but some struggle . thanks!
For Each no As HtmlAgilityPack.HtmlNode In docs.DocumentNode.SelectNodes("//div[contains(@class,'wrap_body')]")
Dim attr As String = no.GetAttributeValue("wrap_body", "")
Next
Below is a sample for getting Inner Html
var html =
@"<body>
<div class='wrap_body text_align_left' style=''>
<div class='some'> hello </div>
<div class='someother'> world </div>
hello world
</div>
</body>";
var htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(html);
var htmlNodes = htmlDoc.DocumentNode.SelectNodes("//body/div");
foreach (var node in htmlNodes)
{
Console.WriteLine(node.InnerHtml);
}