Saturday, May 17, 2008

Escape HTML and XML in Java

HTML and XML escape format is widely used in web and XML transactions.

There is a great utility for this purpose in Java world : Lang package in apache commons project

Download commons-lang and put the commons-lang-xxx.jar file in your classpath or in your project.

The StringEscapeUtils class is your key class here.

Use static escapeXml() , escapeHtml() , unescapeXml() , unescapeHtml() methods.

String escaped = StringEscapeUtils.escapeXml("");

Great & Lifesaving , thanks apache again !


3 comments:

Járai Csaba said...

Thanks!

Anonymous said...

Thanks

Anonymous said...

Thanks!