1

This is regarding decoding the special characters from the XML file which is internally retrieved from the data base through parser. The partial data that we got is

"qutes", sigle quotes', namne? 

Here, the XML character ' " should be converted to plain quotes like ". In the similar way ''' which is a single quote(apostrophes). Is there any way to do this in JAVA. Kindly, let me know if you need any information.

Cœur
  • 37,241
  • 25
  • 195
  • 267
user1338410
  • 11
  • 1
  • 3
  • possible duplicate of [How to decode encoded special XML characters in a string?](http://stackoverflow.com/questions/2241787/how-to-decode-encoded-special-xml-characters-in-a-string) – Perception Apr 17 '12 at 10:14

4 Answers4

2

If you parse your XML with Stax or DOM this would be handled automatically. If not there is a duplicate thread here: How to decode encoded special XML characters in a string?

Community
  • 1
  • 1
barsju
  • 4,408
  • 1
  • 19
  • 24
1

Try this: StringEscapeUtils.unescapeHTML()

Unescapes a string containing entity escapes to a string containing the actual Unicode characters corresponding to the escapes. Supports HTML 4.0 entities. For example, the string "&lt;Fran&ccedil;ais&gt;" will become "<Français>" If an entity is unrecognized, it is left alone, and inserted verbatim into the result string. e.g. "&gt;&zzzz;x" will become ">&zzzz;x".

jensgram
  • 31,109
  • 6
  • 81
  • 98
DonCallisto
  • 29,419
  • 9
  • 72
  • 100
0

Use:

http://docs.oracle.com/javase/7/docs/api/javax/xml/bind/DatatypeConverter.html#parseString%28java.lang.String%29

Also consider to use JAXB, which will do all the conversions for you.

Puce
  • 37,247
  • 13
  • 80
  • 152
  • there was no error - it simply didn't decode the standard set of entities for XML, I tried something like: "one&two" and the underlying method returned the same string? – XXL Aug 28 '13 at 09:48
0

You can used PrintWriter . println. You can also now use XPL to store data rather than XML. XPL is just like XML, but allows special characters in text elements.

Roger F. Gay
  • 1,830
  • 2
  • 20
  • 25