Moving Elements Up and Down
Hi, I am not entirely sure the best way to move an Element up one, or down one. It would be very convenient to have a specific function to copy the entire contents of an Element (all attributes, and text) and then to move it to any place within the current Document. I looked at #135, but this seems to be addressing moving to a new document.
This would be useful for copying items, i.e. myXMLElement=myBaseXMLElement->FirstChildElement("Class1")->FirstChildElement("copyItem"); myOtherXMLElement->CopyElement(myXMLElement, afterMyDestinationElement); or myOtherXMLElement->MoveElement(myXMLElement, afterMyDestinationElement); //this deletes tmyXMLElement after copying it.
Is there an existing way to do this? I have tried a few methods, but I have not found something that I can use correctly.
Copying can be done with ShallowClone(), but that doesn't copy sub-nodes, and certainly doesn't have the rich functionality you are proposing. I think having a DeepClone() would solve many of these sort of use cases (moving elements between trees), and DeepClone() combined with the existing would at least give the functionality you want.
Thanks @leethomason, the DeepClone() might be a nice feature for the future!
+1 for DeepClone