i have a problem with html agility pack i am unable to remove div content from html and place the same content on top of all divs. like
<body>
<div class="1">...</div>
<div class="2">...</div>
<div class="3">...</div>
</body>
now i want to remove/sort third div and place it on top of first div. Any help would be great. Thanks!
You should try this code:
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml("<html><body><div class=\"1\">...</div><div class=\"2\">...</div><div class=\"3\">...</div></body></html>");
HtmlNode body = doc.DocumentNode.SelectSingleNode("/html/body");
HtmlNode div = body.SelectSingleNode("div[@class='3']");
if (div != null) {
div.Remove();
body.InsertBefore(div, body.FirstChild);
}