rynop All American 829 Posts user info edit post |
I am simply trying to write DOM to an xml file. Here is my code: // This method writes a DOM document to a file public static void writeXmlFile(Document doc, String filename) { try { // Prepare the DOM document for writing DOMSource source = new DOMSource(doc); // Prepare the output file File file = new File(filename); file.createNewFile(); StreamResult result = new StreamResult(file); // Write the DOM document to the file Transformer xformer = TransformerFactory.newInstance().newTransformer(); xformer.transform(source, result); } catch (TransformerConfigurationException e) { } catch (TransformerException e) { } catch (IOException ioe){ } }
The incoming filename string is c:\coverted\test.xml. If I create my StreamResult by doing new StreamResult(System.out), it prints out fine. What the hell am i doing wrong? I tried throwin in "file.createNewFile();" because I thougth the transformer might not create the file if it does not exist...but now it just creates the file, and doesnt put any data in it. thx in advance. 1/18/2006 5:59:55 PM |