I'm using freemarker in Prints. Sometimes I'm getting an invalid XML character code error. I'm can not control what data is coming from API JSON.IN JSON I'm getting data like this format
{"key":"HMA \u2013AZACITIDINE"}
I'm using freemarker in Prints. Sometimes I'm getting an invalid XML character code error. I'm can not control what data is coming from API JSON.IN JSON I'm getting data like this format
{"key":"HMA \u2013AZACITIDINE"}
If you don't have any control over the data you're getting from your API, you can use a regex to remove all the invalid characters.
For XML 1.0, another StackOverflow answer recommends using something like this:
// Regex matches illegal XML 1.0 characters
String xml10pattern = "[^\u0009\u0020-\uD7FF\uE000-\uFFFD\ud800\udc00-\udbff\udfff\r\n]";
String badXmlData = "\u0011 YOUR XML STRING HERE";
// Replace all the matching (illegal) characters with the empty string, removing them
String cleanXmlData = badXmlData.replaceAll(xml10pattern, "");