I\'m using Spring, CXF and Hibernate to build a WebService that perform search queries on a foreign database that I have read-only access.
The problem is that some entri
The top-rated answer didn't work for me, as the given Unicode encoding was rejected. With a slight alteration however, it displayed the desired behaviour:
public static String CleanInvalidXmlChars(String text, String replacement) {
String re = "[^\\u0009\\u000A\\u000D\\u0020-\\uD7FF\\uE000-\\uFFFD\\u0001\\u0000-\\u0010\\uFFFF]";
return text.replaceAll(re, replacement);
}