public void MergeWith(MarkupElement element) { //element cannot be a text node! if (element is MarkupTextElement) { throw new Exception("Unable to merge with a text element!"); } //merge the elements attributes MergeWith(element.Attributes); //add all of the elements children IEnumerator<Node> children = element.Children.GetEnumerator(); while (children.MoveNext()) { element.AddChild(children.Current); } //clean up children.Dispose(); }