code: public static String escape(CharSequence s) {
  		StringBuilder str = new StringBuilder();
  		int len = s.length();
  		for (int i = 0; i < len; ++i) {
  			char c = s.charAt(i);
  			if (c == '&') str.append("&amp;");
  			else if (c == '"') str.append("&quot;");
  			else if (c == '\'') str.append("&apos;");
  			else if (c == '>') str.append("&gt;");
  			else if (c == '<') str.append("&lt;");
  			else if (c < 32) str.append("&#").append((int)c).append(';');
  			else str.append(c);
  		}
  		return str.toString();
  	}
docs: Escape a string to include it in XML (this is automatically called by other methods of this class when needed).