I have an XML file that\'s the output from a database. I\'m using the Java SAX parser to parse the XML and output it in a different format. The XML contains some invalid c
public static String stripInvalidXmlCharacters(String input) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
if (XMLChar.isValid(c)) {
sb.append(c);
}
}
return sb.toString();
}