[jdom-interest] Formatting XML

Oliver Hirschi o.hirschi at bluewin.ch
Wed Feb 27 06:53:30 PST 2008


Hi

I have an XML generated with JDOM 1.1 and output it to a file 
(pretty.xml) in PrettyFormat.
Now, I read the above file and output it with JDOM to another file 
(raw.xml) in RawFormat:
----------------
SAXBuilder builder = new SAXBuilder();
Document oDoc_Chart = builder.build("c:\\000\\pretty.xml");

XMLOutputter oXMLOutputter = new XMLOutputter();
Format oFormat = Format.getRawFormat();
oXMLOutputter.setFormat(oFormat);
FileOutputStream oFileOutputStream = new 
FileOutputStream("c:\\000\\raw.xml");
OutputStreamWriter oOutputStreamWriter = new 
OutputStreamWriter(oFileOutputStream, "UTF-8");
oXMLOutputter.output(oDoc_Chart, oOutputStreamWriter);
oOutputStreamWriter.close();
oFileOutputStream.close();
----------------

The new file (raw.xml) is still pretty-formated and NOT raw - Why???

Thanks & Regards,
Oliver Hirschi 




More information about the jdom-interest mailing list