<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>The following code does NOT produce the UTF-8 that I had expected. As far as I can tell the Text element only seems to work with ASCII text. I would have expected it to work with non-ASCII text. Or am I doing something dumb?<br><br> private void jdomTest() throws IOException<br> {<br> Element element = new Element("doc");<br> element.addContent(new Text("\u4E2D\u6587"));<br> Document document = new Document(element);<br><br> StringWriter out = new StringWriter();<br> Format f = Format.getPrettyFormat();<br> new
XMLOutputter(f).output(document, out);<br> System.out.println("XML: "+out);<br> }<br><br></div></div><br>
</body></html>