I have an XML file (on the left) and I want to create multiple files (on the right):
file1:
Nodes in the DOM have a concept of their owning document (hence your WRONG_DOCUMENT_ERR).
WRONG_DOCUMENT_ERR
So you need to import the node from the original DOM to your new one. See Document.importNode()