List of utility methods to do XML Sanitize
String | sanitizeJson4XML(String jsonString) sanitizeJson4XML - Sanitize a JSON string so it converts to XML without error. jsonString = jsonString.trim(); if (!jsonString.startsWith("{")) { jsonString = "{\"Anonymous\":" + jsonString + "}"; return jsonString; |
String | sanitizeXML(String xml) Remove all unnecessary white spaces, tabs and line breaks from XML string. return xml.replace("\n", "").replace("\r", "").replace("\t", "").replaceAll(">\\s+<", "><").trim(); |
String | SanitizeXmlString(String xml) Sanitize Xml String if (xml == null || xml.isEmpty()) { return xml; StringBuilder buffer = new StringBuilder(xml.length()); for (int i = 0; i < xml.length(); i++) { if (IsLegalXmlChar(xml.charAt(i))) { buffer.append(xml.charAt(i)); return buffer.toString(); |
String | sanitizeXmlTypeName(String name) Since XML names can not contain all characters JSON names can, we may need to replace characters. StringBuilder sb; int changes = 0; if (name.endsWith("[]")) { do { name = name.substring(0, name.length() - 2); ++changes; } while (name.endsWith("[]")); sb = new StringBuilder(name); ... |