public static String xmlize(String s){
  s=s.replaceAll("&","&amp;");
  s=s.replaceAll("<","&lt;");
  s=s.replaceAll(">","&gt;");
  s=s.replaceAll("\"","&quot;");
  int charCount=s.length();
  for (int iter=0; iter < charCount; iter++) {
    char c=s.charAt(iter);
    if (c > 127) {
      StringBuilder b=new StringBuilder();
      for (int counter=0; counter < charCount; counter++) {
        c=s.charAt(counter);
        if (c > 127) {
          b.append("&#x");
          b.append(Integer.toHexString(c));
          b.append(";");
        }
 else {
          b.append(c);
        }
      }
      return b.toString();
    }
  }
  return s;
}

public static String xmlize ( String s ) { s = s . replaceAll ( "&" , "&amp;" ) ; s = s . replaceAll ( "<" , "&lt;" ) ; s = s . replaceAll ( ">" , "&gt;" ) ; s = s . replaceAll ( "\"" , "&quot;" ) ; int charCount = s . length ( ) ; for ( int iter = 0 ; iter < charCount ; iter ++ ) { char c = s . charAt ( iter ) ; if ( c > 127 ) { StringBuilder b = new StringBuilder ( ) ; for ( int counter = 0 ; counter < charCount ; counter ++ ) { c = s . charAt ( counter ) ; if ( c > 127 ) { b . append ( "&#x" ) ; b . append ( Integer . toHexString ( c ) ) ; b . append ( ";" ) ; } else { b . append ( c ) ; } } return b . toString ( ) ; } } return s ; }
converts a string to xml body string
