This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes How to have HTML entities in a XML element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to have HTML entities in a XML element" Watch "How to have HTML entities in a XML element" New topic

How to have HTML entities in a XML element

Srikkanth Mohansundaram

Joined: Apr 10, 2008
Posts: 16

I have been using XMLBeans for parsing xml documents. It works fine but when i have HTML entities like ® © there is a parsing error in the document. I tried to modify the type of the element to CDATA but then the HTML entities are changed and & is replaced with & so it doesn't render right on the page.

This is error which i have been getting org.apache.xmlbeans.XmlException: org.xml.sax.SAXParseException: The entity "reg" was referenced, but not declared.

Paul Clapham

Joined: Oct 14, 2005
Posts: 19719

XML knows nothing about HTML entities, so by using them, you make the document not well-formed.

Your best option is to not use them. Instead, use the corresponding XML character entities. Another alternative is to provide the document with a DTD which defines all of the entities you plan to use. But really I think it's better not to speak XML with an HTML accent.
Have you checked out Aspose?
subject: How to have HTML entities in a XML element
It's not a secret anymore!