I am using org.apache.commons.lang.StringEscapeUtils to escape HTML tags:
StringEscapeUtils.escapeHtml(str);
What I want is to avoid escaping few particular tags. e.g.
<h1>this is h1</h1>
<ul>
<li></li>
<li></li>
</ul>
After escaping it should connvert all < to < and > to > except <ul> and <li> tag. Here i don't want to escape <ul> <li> tags because in HTML page i have to show content as list so i need ul and li.
How can i do this in java and javascript.