[jdom-interest] Special characters in XML?

David M. Goudreau david_goudreau at crosscommerce.com
Thu Mar 15 17:53:17 PST 2001

I'm trying to store special characters such as ® (the registered trademark
symbol) in my XML string and I'm having difficulties.  It is updated through
JDOM and stored in my database just fine using JDOM, but when it tries to
instantiate the document object from the string I get the following error:

org.jdom.JDOMException: Error on line 2: The entity "reg" was referenced,
but not declared.
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:348)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:440)

The XML that causes the problem is:

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE root><root
sub_id="84"><folder name="tester" cdate="3/15/01" id="f_272" /><folder
name="&reg;" cdate="3/15/01" id="f_273" /></root>

Is there an easy way to handle special characters?  I would think this
conversion would be automatic depending on the encoding you use.  Do I need
to use a different encoding?  What's the best way to handle special
characters?  Or do I need to create a DTD to define the "reg" entity?
Thanks in advance.


More information about the jdom-interest mailing list