Here you can find the source of toXMLString(String str)
static String toXMLString(String str)
//package com.java2s; //License from project: Open Source License public class Main { static String toXMLString(String str) { return str.replaceAll("&", "&").replaceAll("\"", """) .replaceAll(">", ">").replaceAll("<", "<"); }//from w ww . ja va 2s. c o m }