[jdom-interest] How to specify Unicode for XMLOutputter
Woude, Peter van der
woudep at logica.com
Thu Aug 2 17:21:10 PDT 2001
Hi,
I would like to heed the warning given in the documentation of the method
'outputString(Document doc)' of XMLOutputter.
Here it is: "Warning: a String is Unicode, which may not match the
outputter's specified encoding".
I can see, then, that I need to change the XMLOutputter's default setting of
"UTF-8" to "unicode" to match the Java String...?
I'm not sure how to do this... I just want to make sure that the following
code works all the time.
xmlout.setEncoding( "ISO 10646-1" ); <- what to specify in here to make sure
I'm right
I haven't tested it to say it "doesn't" work, I just want to be logically
correct to begin with.
...
Element root = new Element( "root" );
root.addContent( (new Element( "sub" ) ).setText( "bla" ));
Document doc = new Document( root );
// serialize it to a String
XMLOutputter xmlout = new XMLOutputter();
xmlout.setEncoding( "ISO 10646-1" ); <- what to specify in here to make sure
I'm right
asXML = xmlout.outputString( doc );
More information about the jdom-interest
mailing list