code: public static String convertCharsToXml(String input) {
  		StringBuffer result = new StringBuffer();
  		for(int i=0; i<input.length(); i++) {
  			switch(input.charAt(i)) {
  				case '<':	result.append("&lt;"); break;
  				case '>':	result.append("&gt;"); break;
  				case '"':	result.append("&quot;"); break;
  				case '\'':	result.append("&apos;"); break;
  				case '&':	result.append("&amp;"); break;
  				default:	result.append(input.charAt(i));
  			}
  		}
  		return result.toString().trim();
  	}
docs: Convenience method to convert XML reserved chars.
  
  @param input String to be converted.
  @return Converted string.