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.
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.