Java Utililty Methods XML Escape

List of utility methods to do XML Escape

Description

The list of methods to do XML Escape are organized into topic(s).

Method

Stringescape4XML(long study_id, String xmlStr)
escape XML
if (xmlStr == null)
    return null;
StringBuilder result = new StringBuilder();
StringCharacterIterator sci = new StringCharacterIterator(xmlStr);
char c = sci.current();
while (c != CharacterIterator.DONE) {
    if (c == '<') {
        result.append("&lt;");
...
StringescapeNonXmlTagSymbols(String string)
escape Non Xml Tag Symbols
StringBuffer result = new StringBuffer();
StringCharacterIterator iterator = new StringCharacterIterator(string);
Character character = iterator.current();
while (character != CharacterIterator.DONE) {
    if (non_xml_pattern.matcher(character.toString()).matches())
        result.append(character);
    character = iterator.next();
return result.toString();
StringescapeXML(String s)
escape XML
final StringBuilder result = new StringBuilder();
final StringCharacterIterator iterator = new StringCharacterIterator(s);
char ch = iterator.current();
while (ch != CharacterIterator.DONE) {
    if (ch == '<') {
        result.append("&lt;");
    } else if (ch == '>') {
        result.append("&gt;");
...