Aspose.Words.Examples.CSharp.Programming_Documents.Working_with_Fields.RenameMergeFields.MergeField.RemoveSameParent C# (CSharp) Method

RemoveSameParent() private static method

Removes nodes from start up to but not including the end node. Start and end are assumed to have the same parent.
private static RemoveSameParent ( Node startNode, Node endNode ) : void
startNode Node
endNode Node
return void
            private static void RemoveSameParent(Node startNode, Node endNode)
            {
                if ((endNode != null) && ((Node)startNode.ParentNode != (Node)endNode.ParentNode))
                    throw new ArgumentException("Start and end nodes are expected to have the same parent.");

                Node curChild = startNode;
                while ((curChild != null) && (curChild != endNode))
                {
                    Node nextChild = curChild.NextSibling;
                    curChild.Remove();
                    curChild = nextChild;
                }
            }