开发者

writing xml bug

开发者 https://www.devze.com 2023-01-08 05:48 出处:网络
public static void writeXmlFile(Document doc, String filename) { try { 开发者_如何转开发// Prepare the DOM document for writing
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 ?


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.


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

I hope that isn't your real exception handling.

0

精彩评论

暂无评论...
验证码 换一张
取 消