If I am not wrong Document object of DOM is memory representation if xml document. It is not wrapper on the physical file. So if you want your changes to be reflected in the file, you need to save the file explicitly.

Still, you're creating a new element, but you are not adding it to the DOM tree. In addition, if you check the javadoc for appendChild, you'll see that it removes its argument from the tree. So, yes, you are removing one element from the tree, and not adding one.