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

RemoveChild (keepGrandChildren) with em inside returns strange results

description

Here's a simple snippet which attempts to strip out the span element while keeping everything else:
        var document = new HtmlDocument();
        document.LoadHtml("<div><span>a<em>b</em>c</span></div>");
        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.

Result:
<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?

comments

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.