code: public static String encodeAsXMLName(String s) {
  
  		StringBuilder sb = new StringBuilder("_");
  		for (byte b : s.getBytes(Charset.forName("UTF-8"))) {
  			sb.append(Integer.toHexString((b >>> 4) & 0xF));
  			sb.append(Integer.toHexString(b & 0xF));
  		}
  
  		return sb.toString();
  	}
docs: This will encode the given string as a valid XML name. The format will be
  an initial underscore followed by the hexadecimal representation of the
  string.
  
  The method will throw an exception if the argument is null.
  
  @param s
  String to encode as an XML name
  
  @return valid XML name from String
  
  @throws NullPointerException if the argument is null