How do I write a DOM document as an XML file?
Created May 4, 2012
Pramod Hirole Use xerces parser from apache.
You should use the XMLSerializer class to serialise dom to xml file.
Here is code sniplet.
// import following package import org.apache.xml.serialize.*; // following code serializes // dom to xml file OutputFormat of = new OutputFormat("XML","UTF-8",true); XMLSerializer serializer = new XMLSerializer(); serializer.setOutputFormat(of); serializer.setOutputstream(new FileOutputstream("xmlfile.xml")); serializer.serialize(dom);You can get the xerces parser from Apache.