Cutting and Pasting within a Document
This example swaps the position of the first two chapters in a document. When chapter one is inserted before chapter three, it is the same as a cut and paste; it is not a copy of the node, but the node itself that is being moved.
var doc = Application.openDocument("sample1.xml");
//Get the nodes contining chapters one and three from the document
//Chapter three will be the node to insert before
var chapters=doc.getElementsByTagName("chapter");
var chapter1 = chapters.item(0);
var chapter3 = chapters.item(2);
var book = doc.getElementsByTagName("book").item(0);
//chapter1 is the new node, and chapter3 is the reference
book.insertBefore(chapter1,chapter3);