*/
protected void writeDOMTree(Document doc, File file) throws IOException {
OutputStream out = new FileOutputStream( file );
PrintWriter wri = new PrintWriter(out);
wri.write("<?xml version=\"1.0\"?>\n");
(new DOMElementWriter()).write(doc.getDocumentElement(), wri, 0, " ");
wri.flush();
wri.close();
// writers do not throw exceptions, so check for them.
if (wri.checkError()){
throw new IOException("Error while writing DOM content");