This project has moved and is read-only. For the latest updates, please go here.

Problem with ordering when RemoveChild called

Topics: Developer Forum
Mar 22, 2007 at 12:19 AM

I have a structure like this


And I'm parsing it like this:

HtmlNodeCollection nodes = _htmlDocument.DocumentNode.SelectNodes("//*");

foreach (HtmlNode node in nodes)
HtmlNode parentnode = node.ParentNode;
HtmlTextNode textnode1 = node.OwnerDocument.CreateTextNode("START");
parentnode.InsertBefore(textnode1, node);

HtmlTextNode textnode2 = node.OwnerDocument.CreateTextNode("END");
parentnode.InsertAfter(textnode2, node);

parentnode.RemoveChild(node, true);


The problem is that if I call RemoveChild, it reorders the two lines in the leveltwo innerhtml. If I don't call removechild, it keeps them in the correct order.

Could this be a bug? If so, is there a workaround for it?


Mar 23, 2007 at 6:48 PM

I think I found the problem and a fix for this---I'll post this to the "issues" secton under item 9113.