This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Those instances of xmlns="" mean that those elements are not in any namespace. In your original string they are in the default namespace, but something has changed in your processing which caused that namespace information to be lost, correct?
So that must be your DOM parser's fault. And that happens because DOM parsers are not namespace-aware by default. (Not a very good default, but that's how it is.) Check out the setNamespaceAware() method of DocumentBuilderFactory and use it in your code.
(By the way, is there a reason you did this XML processing instead of just writing the string directly to the file?)