Java tutorial
//package com.java2s; public class Main { /** * XML attribute value Encode * @param s xml attribute values * @return convert "&"->"&", "<"->"<", ">"->">" */ public static String encodeXMLReservedWords(String s) { if (s.contains("&")) { s = s.replaceAll("&", "&"); } if (s.contains("<")) { s = s.replaceAll("<", "<"); } if (s.contains(">")) { s = s.replaceAll(">", ">"); } return s; } }