I have Finnish characters in my text (for example ä, ö and å) that are unsafe in XML, is there any library/framwork for this purpose?
+1
A:
StringEscapeUtils from Commons Lang has the escapeXML method which will suit your needs.
Valentin Rocher
2010-02-08 09:21:42
+2
A:
XML supports Unicode, so the only thing you really need to escape are the five basic XML entities (gt, lt, quot, amp, apos). If you use StringEscapeUtils.escapeXML, it will turn all your ä, ö and å into ugly \uabcd stuff.
Thilo
2010-02-08 09:26:29
Incidentally, there are some characters that the XML spec treats as illegal, no matter how you try to encode them. The ASCII NUL character for example.
Stephen C
2010-02-08 11:49:49