You can use
identity transform to serialize your DOM document into raw XML. Also, if you're using Xerces and don't mind importing org.apache.* stuff in your code, it also has a class named XMLSerializer which can produce a whole lot better-looking XML than the javax.transform.* API (and faster).