private static String escapeXML(String s){
  if (s == null) {
    return null;
  }
  final int length=s.length();
  StringBuffer b=new StringBuffer();
  for (int i=0; i < length; i++) {
    char c=s.charAt(i);
switch (c) {
case '&':
      b.append("&amp;");
    break;
case '<':
  b.append("&lt;");
break;
case '>':
b.append("&gt;");
break;
default :
b.append(c);
break;
}
}
return b.toString();
}

private static String escapeXML ( String s ) { if ( s == null ) { return null ; } final int length = s . length ( ) ; StringBuffer b = new StringBuffer ( ) ; for ( int i = 0 ; i < length ; i ++ ) { char c = s . charAt ( i ) ; switch ( c ) { case '&' : b . append ( "&amp;" ) ; break ; case '<' : b . append ( "&lt;" ) ; break ; case '>' : b . append ( "&gt;" ) ; break ; default : b . append ( c ) ; break ; } } return b . toString ( ) ; }
a very very basic xml escaper .
