public RemoveChild ( |
||
oldChild | The node being removed. May not be null. | |
keepGrandChildren | bool | true to keep grand children of the node, false otherwise. |
return |
public HtmlNode RemoveChild(HtmlNode oldChild, bool keepGrandChildren)
{
if (oldChild == null)
{
throw new ArgumentNullException("oldChild");
}
if ((oldChild._childnodes != null) && keepGrandChildren)
{
// get prev sibling
HtmlNode prev = oldChild.PreviousSibling;
// reroute grand children to ourselves
foreach(HtmlNode grandchild in oldChild._childnodes)
{
InsertAfter(grandchild, prev);
}
}
RemoveChild(oldChild);
_outerchanged = true;
_innerchanged = true;
return oldChild;
}
HtmlNode::RemoveChild ( |
public static void RemoveChildKeepGrandChildren ( HtmlNode parent , HtmlNode oldChild ) { if ( oldChild.ChildNodes != null ) { HtmlNode previousSibling = oldChild.PreviousSibling; foreach ( HtmlNode newChild in oldChild.ChildNodes ) { parent.InsertAfter ( newChild , previousSibling ); previousSibling = newChild; // Missing line in HtmlAgilityPack } } parent.RemoveChild ( oldChild ); }