public static void writeXMLDocument(Document doc,String filename){
  try {
    TransformerFactory transformerFactory=TransformerFactory.newInstance();
    Transformer transformer;
    transformer=transformerFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT,"yes");
    DOMSource source=new DOMSource(doc);
    StreamResult result=new StreamResult(new File(filename));
    transformer.transform(source,result);
    log.fine("writing operation to " + filename + " successful!");
  }
 catch (  TransformerConfigurationException e) {
    log.warning(e.getMessage());
  }
catch (  TransformerException e) {
    log.warning(e.getMessage());
  }
}

public static void writeXMLDocument ( Document doc , String filename ) { try { TransformerFactory transformerFactory = TransformerFactory . newInstance ( ) ; Transformer transformer ; transformer = transformerFactory . newTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . INDENT , "yes" ) ; DOMSource source = new DOMSource ( doc ) ; StreamResult result = new StreamResult ( new File ( filename ) ) ; transformer . transform ( source , result ) ; log . fine ( "writing operation to " + filename + " successful!" ) ; } catch ( TransformerConfigurationException e ) { log . warning ( e . getMessage ( ) ) ; } catch ( TransformerException e ) { log . warning ( e . getMessage ( ) ) ; } }
writes the xml document to the particular file specified as argument
