Reputation: 6422
I am creating a web service in Java and I want to clean up my strings so they are valid xHTML. I'd also like to preserve line breaks.
So for example, if my user enters a string like this:
This course is offered <3> times a year & is scheduled for:
October 2011
November 2012 and
December 2013
I want to clean up the string to look like this:
This course is offered <3> times a year & is scheduled for:
October 2011
November 2012 and
December 2013
How can I achieve this in Java?
Thanks
Upvotes: 0
Views: 1649
Reputation: 7225
This doesn't match your question exactly, but it appears that the answer is what you're looking for Recommended method for escaping HTML in Java.
Summary: StringEscapeUtils.escapeHtml() from apache commons
Upvotes: 0