mynameisanthpny
mynameisanthpny

Reputation: 689

writing xml bug

public static void writeXmlFile(Document doc, String filename) {
     try {
           // Prepare the DOM document for writing
           Source source = new DOMSource(doc);

           // Prepare the output file
           File file = new File(filename);
           Result 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) {
     }
}

i am using this function to write xml into a file, everything comes fine but one line is being added as follows just before last ending tag.

[Mar 13 15:40:16] INFO (ConnectionController.java:342) - 

i am neer using this class and why is this mar 13 date even i dont know

is it a common issue ?

Upvotes: 0

Views: 96

Answers (2)

user207421
user207421

Reputation: 311048

Clearly something else is writing to the same file. Looks like a logger to me.

I hope that isn't your real exception handling.

Upvotes: 0

Andreas Dolk
Andreas Dolk

Reputation: 114817

Can we exclude that the document contains the text already? Because that would be a pretty easy solution: the error wouldn't occur durcing printing but maybe during document generation.

To investigate, you could just iterate over the child nodes of root (not elements) and check whether there is a suspicious text or cdata node near the end.

At least it looks like a log message, generated when the machine system date was set to March, 13 2010.

Upvotes: 0

Related Questions