[jdom-interest] writing XML to a String

Lorenzo Gonzalez lgonzalez at gltg.com
Wed Aug 30 08:36:14 PDT 2000

> I wanted to use XMLOutputter to output a Document to a


	ByteArrayOutputStream xmlBaos = new

	XMLOutputter outputter = new XMLOutputter("",false); // machine-readable
	outputter.output(xmlDoc, xmlBaos);

	String xmlString = new String(xmlBaos.toByteArray());


Or something like that...


-----Original Message-----
From: jdom-interest-admin at jdom.org
[mailto:jdom-interest-admin at jdom.org]On Behalf Of Cameron Smith
Sent: Wednesday, August 30, 2000 6:56 AM
To: 'jdom-interest at jdom.org'
Subject: [jdom-interest] writing XML to a String

I wanted to use XMLOutputter to output a Document to a String/StringBuffer,
which would then be wrapped up in a larger message by another system
component and sent off somewhere.

Unfortunately output() can only use a print stream, and java.io only
provides a StringWriter and no OutputStream -> Writer class.  I have a
feeling I'm missing something obvious - anyone have a suggestion?

Alternatively, does the latest cvs build now have an output(Writer) method?
(I know the javadocs aren't totally in sync with builds).


	Cameron Smith, Software Developer
	Entranet Ltd

	Email:   cameron.smith at entranet.co.uk
	Tel:      44 (0) 131 200 6222
Fax:      44 (0) 131 200 6200

This information is confidential and must not be copied, used or
	disclosed without Entranet's prior written consent. If you have
	received this information in error please notify the system
	manager immediately.

	Entranet - creators of online commerce

	Entranet Limited
        Registered office - 2 Apsley Way London, NW2 7LF
	Registered in England No. 3267855


To control your jdom-interest membership:

More information about the jdom-interest mailing list