protected String escapeXmlSpecialCharacters ( String url ) { // https://stackoverflow.com/questions/1091945/what-characters-do-i-need-to-escape-in-xml-documents return url . replace ( "&" , "&amp;" ) // must be escaped first!!! . replace ( "\"" , "&quot;" ) . replace ( "'" , "&apos;" ) . replace ( "<" , "&lt;" ) . replace ( ">" , "&gt;" ) ; }
Escape special characters in XML