JADE provides methods that change the tree to add, move, copy, and remove nodes. The following example changes the order of the books in the library1.xml document.
reorder1();
vars
doc : JadeXMLDocument;
books : JadeXMLElementArray;
begin
create doc;
doc.parseFile('library1.xml');
create books;
doc.rootElement.getElementsByTagName('book', books);
books[2].moveBefore(books[1]);
write doc.writeToString;
delete books;
delete doc;
end;
The output from the reorder1 method shown in the previous example is as follows.
<?xml version="1.0"?>
<!--An example XML document-->
<library>
<book isbn="1-876590-17-3">
<title>False Memory</title>
<author>Dean Koontz</author>
</book>
<book isbn="0-246-13655-3">
<title>Mystery</title>
<author>Peter Straub</author>
</book>
</library>