Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving Elements Up and Down #286

Open
ghost opened this issue Mar 1, 2015 · 3 comments
Open

Moving Elements Up and Down #286

ghost opened this issue Mar 1, 2015 · 3 comments

Comments

@ghost
Copy link

ghost commented Mar 1, 2015

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.

@leethomason
Copy link
Owner

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.

@ghost
Copy link
Author

ghost commented Mar 12, 2015

Thanks @leethomason, the DeepClone() might be a nice feature for the future!

@petko
Copy link

petko commented Jun 30, 2016

+1 for DeepClone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants