Here you can find the source of serialiseDOM(Document doc, String filepath)
public static void serialiseDOM(Document doc, String filepath)
//package com.java2s; // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell import java.io.File; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; public class Main { public static void serialiseDOM(Document doc, String filepath) { Transformer transformer;//w ww .j a v a 2 s. c o m try { transformer = TransformerFactory.newInstance().newTransformer(); Result output = new StreamResult(new File(filepath)); Source input = new DOMSource(doc); transformer.transform(input, output); } catch (TransformerConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TransformerFactoryConfigurationError e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TransformerException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }