Reputation: 1176
I have an xml in which it contails <br/>
tag in the element data fiels. I am able to parse it using string builder in Sax parser. Now i want to trim down some of the tags and return back an xml response. In the response xml source i am getting the tag replaces as <br/>
. My concern is that the "<" gets replaced by <
but the ">" tag does not get replaced by >
. Anybody has idea of how to sort out this problem.
Upvotes: 0
Views: 969
Reputation: 3361
You should escape for XML. Try EscapeUtils from Apache Commons Lang.
Mind that also Java may be having trouble dealing with it.
I prefer first to escapeJava and after that escapeXML.
Usage:
String escapedStr= StringEscapeUtils.escapeJava(yourString);
escapedStr= StringEscapeUtils.escapeXML(yourString);
Apache Commons Lang download link.
Upvotes: 2