Let's say I want to remove the span tag from this html:
<html><span>we do like <b>bold</b> stuff</span></html>
I expect this piece of code to do what I am after
string html = "<html><span>we do like <b>bold</b> stuff</span></html>"; HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(html); HtmlNode span = doc.DocumentNode.Descendants("span").First(); span.ParentNode.RemoveChild(span, true); //second parameter is 'keepGrandChildren'
But the conclusion is as follows:
<html> stuff<b>bold</b>we do like </html>
It seems that the reversal of child nodes is within range. Am I doing something wrong?
source share