This project has moved. For the latest updates, please go here.

RemoveChild (keepGrandChildren) with em inside returns strange results


Here's a simple snippet which attempts to strip out the span element while keeping everything else:
        var document = new HtmlDocument();
        var span = document.DocumentNode.Descendants().First(n => n.Name == "span");
        span.ParentNode.RemoveChild(span, true);
        var result = document.DocumentNode.OuterHtml;
Strangely, once the span element is stripped out, the a and c characters switches positions.

<div>c<em>b</em>a</div> Expected behavior:
<div>a<em>b</em>c</div> Anyone know why this is happening? Is it a bug?


johnnyoshika wrote Jan 10 at 9:22 AM

@LoganHollins yes, it seems that his is a duplicate of the other 2. I will close this issue.

johnnyoshika wrote Jan 10 at 9:23 AM

It doesn't look like I can close this issue so hopefully a moderator will do that.