Here you can find the source of DOMaXML(Document doc, String nome)
public static void DOMaXML(Document doc, String nome)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.*; import javax.xml.transform.*; import javax.xml.transform.stream.*; import javax.xml.transform.dom.DOMSource; public class Main { public static void DOMaXML(Document doc, String nome) { try {/*from www .ja va 2s . c o m*/ TransformerFactory tf = TransformerFactory.newInstance(); Transformer t = tf.newTransformer(); //result entre o transformador e o arquivo StreamResult sr = new StreamResult(new File(nome)); //resource entre o tranformador e o dom DOMSource doms = new DOMSource(doc); //pasarlle un stream result e un streamSource t.setOutputProperty(OutputKeys.INDENT, "yes"); t.transform(doms, sr); } catch (Exception e) { e.printStackTrace(); } } }