List of utility methods to do XML String Create
String | toXMLString(String string) to XML String if (string == null || string.isEmpty()) return ""; StringBuffer xmlString = new StringBuffer(); int stringLength = string.length(); for (int i = 0; i < stringLength; i++) { char c = string.charAt(i); if (c == '"') xmlString.append("""); ... |
String | toXMLString(String t) to XML String String s = t.toString(); StringBuffer sb = new StringBuffer(); for (int idx = 0; idx < s.length(); idx++) { char ch = s.charAt(idx); if (ch == '<') { sb.append("<"); } else if (ch == '&') { sb.append("&"); ... |
String | toXMLString(String text) Converts a text into a XML string by converting special characters into where corresponding entities. StringBuffer buffer = new StringBuffer(); int len = text.length(); for (int i = 0; i < len; i++) { char ch = text.charAt(i); if ((ch < 0x0020) || (ch > 0x007e)) { buffer.append("&#"); buffer.append((int) ch); buffer.append(";"); ... |
String | toXMLUnescapedText(final String text) to XML Unescaped Text return text.replaceAll("<", "<").replaceAll(">", ">").replaceAll(""", "\"").replaceAll("&", "&"); |