[jdom-interest] writing XML to a String
Raffaele Sena
raff at aromatic.org
Wed Aug 30 08:31:42 PDT 2000
> Here's how I do it currently (against the most recent CVS):
>
> ByteArrayOutputStream byteRep = new ByteArrayOutputStream();
> XMLOutputter docWriter = new XMLOutputter("", false);
>
> xmlWriter.output(document, byteRep);
> String stringRep = byteRep.toString();
>
> This is untested as yet, but it should work.
Yap! This is what I do, and it works fine:
// Convert the result to XML (as String)
XMLOutputter outputter = new XMLOutputter(" ", true);
ByteArrayOutputStream output = new ByteArrayOutputStream();
outputter.output(doc, output);
return output.toString();
-- Raffaele
More information about the jdom-interest
mailing list