import java.io.*; import java.util.*; import javax.xml.parsers.*; import com.sun.org.apache.xml.internal.serialize.*; import org.w3c.dom.*; public void output(String filePath) { try { PrintWriter pwriter = new PrintWriter(new FileOutputStream(filePath)); XMLSerializer serl = new XMLSerializer(pwriter, new OutputFormat("xml", "UTF-8", true)); serl.serialize(doc); pwriter.close(); } catch (FileNotFoundException ex) { } catch (IOException ex) { } }