public static String makeXmlSafe(String text){
  if (StringUtil.isNullOrEmpty(text))   return "";
  text=text.replace(ESC_AMPERSAND,"&");
  text=text.replace("\"",ESC_QUOTE);
  text=text.replace("&",ESC_AMPERSAND);
  text=text.replace("'",ESC_APOSTROPHE);
  text=text.replace("<",ESC_LESS_THAN);
  text=text.replace(">",ESC_GREATER_THAN);
  text=text.replace("\u0000"," ");
  return text;
}

public static String makeXmlSafe ( String text ) { if ( StringUtil . isNullOrEmpty ( text ) ) return "" ; text = text . replace ( ESC_AMPERSAND , "&" ) ; text = text . replace ( "\"" , ESC_QUOTE ) ; text = text . replace ( "&" , ESC_AMPERSAND ) ; text = text . replace ( "'" , ESC_APOSTROPHE ) ; text = text . replace ( "<" , ESC_LESS_THAN ) ; text = text . replace ( ">" , ESC_GREATER_THAN ) ; text = text . replace ( "" , " " ) ; return text ; }
takes in a string , and replaces all xml special characters with the approprate escape strings .
