[jdom-interest] How to not expand entities?

Indrayan, Rahul rindrayan at ets.org
Tue Sep 10 16:16:54 PDT 2002

Again, a question related to the same code: -

import java.io.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;

public class Spike {
	public static void main(String args[]) {
		try {
			SAXBuilder builder = new SAXBuilder(false);
			String xml = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?><!DOCTYPE root SYSTEM \"foo.dtd\"><root><proof>This is
&#xe1; foofoo &#xf3; stuff!</proof></root>";
			new XMLOutputter().output(
				builder.build(new StringReader(xml)),
					new PrintWriter(new
		catch (Exception e) { e.printStackTrace(); }

How do I output the XML to a string so that unicode such as &#xe1; does not
get expanded and the file represent the special characters with their
unexpanded equivalents (i.e., &#xe1;)?


This e-mail and any files transmitted with it may contain privileged or 
confidential information. It is solely for use by the individual for whom 
it is intended, even if addressed incorrectly. If you received this e-mail 
in error, please notify the sender; do not disclose, copy, distribute, or 
take any action in reliance on the contents of this information; and delete 
it from your system. Any other use of this e-mail is prohibited. Thank you 
for your compliance.

More information about the jdom-interest mailing list