private String xmlEscape(String string){
  if (string == null) {
    return null;
  }
  StringBuilder sb=new StringBuilder();
  for (int i=0; i < string.length(); i++) {
    char ch=string.charAt(i);
switch (ch) {
case '<':
      sb.append("&lt;");
    break;
case '>':
  sb.append("&gt;");
break;
case '&':
sb.append("&amp;");
break;
default :
if (ch < 0x20 || ch > 0x7e) {
sb.append("&#" + (int)ch + ";");
}
 else {
sb.append(ch);
}
}
}
return sb.toString();
}

private String xmlEscape ( String string ) { if ( string == null ) { return null ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < string . length ( ) ; i ++ ) { char ch = string . charAt ( i ) ; switch ( ch ) { case '<' : sb . append ( "&lt;" ) ; break ; case '>' : sb . append ( "&gt;" ) ; break ; case '&' : sb . append ( "&amp;" ) ; break ; default : if ( ch < 0x20 || ch > 0x7e ) { sb . append ( "&#" + ( int ) ch + ";" ) ; } else { sb . append ( ch ) ; } } } return sb . toString ( ) ; }
performs escaping of special xml characters . < br > < br >
