Reputation: 86847
I have a string with xml content. When I save it to File
, the results contains tags like < " >
How can I save such a string correctly so that encoded characters are used?
Upvotes: 0
Views: 407
Reputation: 20063
If you are determined to break the XML spec, then use...
http://commons.apache.org/lang/api-2.6/org/apache/commons/lang/StringEscapeUtils.html
The method "unescapeHtml" will do what you require.
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
"<Français>"
will become"<Français>"
If an entity is unrecognized, it is left alone, and inserted verbatim into the result string. e.g.
">&zzzz;x"
will become">&zzzz;x"
.
Upvotes: 1
Reputation: 887767
You can't.
The XML specifcation says that <
, &
, and >
must be escaped.
Upvotes: 1