I think I might have explained that a little badly, basically what I'm trying to do is add a button on a web page before each element and before each of its children, so basically I want to see the tree in series, with a button, then the first element, a button, then the first child of the first element, etc.
How would you go about removing and storing the nested children? Would that slow the program down a lot?
Also, I just found out that I'm getting this error about an element already being present in the tree, does that mean that an XML tree can't have duplicate elements, or that the IDs are the same?