Thank you very much for the reply.
When changing the lines suggested, and leaving only one element to be added to the new xml (just like to code in the original post) nothing happens.
The <book-meta> element is a valid object to be placed under <book> (this is the highest level element automatically inserted in the xml upon creation) based on my edd and dtd.
Adding some alerts in the doWork function I can see that:
after line with var ELEM_BOOK_META, this is actually an element definition object,
after line with var elementBookMeta, this is actually an element object,
but nothing gets inserted in the xml. file.
The strange thing is that by using the originally posted code I can see the elements inserted in the xml file for a sec and then they disappear. If I do the process described in the original post the elements appear in the xml. As a note, if i save the xml file, close it and open it again the added elements are there.