[jdom-interest] Formatting XML
jdom at tuis.net
Wed Feb 27 07:18:27 PST 2008
Raw format is intended to output the file in the same format as it was
imported.... so, if you raw format output a file that was pretty to
start with, it will be unchanged.
Perhaps you are looking for Format.getCompactFormat().
I just wrote a small test program, and ran it against a file that has an
uncommon format. I can confirm that getPrettyFormat() makes it pretty,
getRawFormat leaves u unchanged, and getCompactFormat makes it all on
Oliver Hirschi wrote:
> 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();
> FileOutputStream oFileOutputStream = new
> OutputStreamWriter oOutputStreamWriter = new
> OutputStreamWriter(oFileOutputStream, "UTF-8");
> oXMLOutputter.output(oDoc_Chart, oOutputStreamWriter);
> The new file (raw.xml) is still pretty-formated and NOT raw - Why???
> Thanks & Regards,
> Oliver Hirschi
> To control your jdom-interest membership:
More information about the jdom-interest