Created
January 30, 2011 10:58
-
-
Save miceno/802781 to your computer and use it in GitHub Desktop.
Groovy (java) escape HTML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.lang.StringEscapeUtils | |
// Alternate way to import | |
this.class.classLoader.rootLoader.addURL(new File("/usr/local/java/grails-1.0/lib/commons-lang-2.1.jar").toURL()) | |
xml = ''' | |
<module id="id" version="0.0.1" package="package"> </module> | |
''' | |
StringEscapeUtils.escapeHtml(xml).split("\n").each() {println it } | |
// Result will be | |
// <module id="id" version="0.0.1" package="package"> </module> | |
// Thanks to Alex Kotchnev's Blog: http://www.troymaxventures.com/2008/05/groovy-html-encode.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment