What is the best way to clone a XML document in Javascript?
I tried doing
var newDocument = myDocument.cloneNode(true);
but that just returned null. I also considered doing
var newNode = myDocument.documentElement.cloneNode(true);
but that is not enough for my purposes, since this way the new node has the same ownerDocument as before.
You can do something like the following to clone a XML document: