I have generated an XML file using javax XML transformer. In the XML file thats generated I have the version and the encoding line
<?xml version="1.0" encoding="UTF-8"?>
which is automatically generated in my XML file. Is there any way that I can avoid that from the XML file thats generated.
Here is the transformer that I have used.
public static void printToXML(String fileName){
try{
File file = new File(fileName);
Transformer tr = TransformerFactory.newInstance().newTransformer();
tr.setOutputProperty(OutputKeys.INDENT, "yes");
tr.setOutputProperty(OutputKeys.METHOD,"xml");
tr.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "3");
tr.transform( new DOMSource(dom),new StreamResult(new FileWriter(file)));
}catch(TransformerConfigurationException tcex){
logger.info("TransformerConfigurationException at printToXML method in CSVtoXML.java");
logger.error("TransformerConfigurationException", tcex);
}catch(TransformerException tex){
logger.info("TransformerException at printToXML method in CSVtoXML.java");
logger.error("TransformerException", tex);
}catch(IOException ioex){
logger.info("IOException at printToXML method in CSVtoXML.java");
logger.error("IOException", ioex);
}
}