XML escape code

leduc_124

New Member
I have written a method to check my XML strings for &. I need to modify the method to include the following:'<' &lt
'>' &gt '\' &guot '&' &amp '\' &aposHere is the method\[code\] private String xmlEscape(String s) { try { return s.replaceAll("&(?!amp;)", "&"); } catch (PatternSyntaxException pse) { return s; }} // end xmlEscape()\[/code\]Here is the way I am using it\[code\] sb.append(" <Host>" + xmlEscape(url.getHost()) + "</Host>\n");\[/code\]How can I modify my method to incorporate the rest of the symbols?
 
Back
Top