Do you mean like this?
You already have revised the xml inside the DOM object, and you want just to save the xml under it?
If so, try this:
The DOM implementation you used to revise the xml, can do it for you too.
private static final
String MY_FILE = "revised.xml";
....do the xml revision here
PrintWriter writer = new PrintWriter(new FileWriter(MY_FILE));
writer.println(((DocumentImpl)
doc).saveXML(null));
writer.close();
The 'doc' variable is your variable that 'is a' DocumentImpl.