-
-
Save dsummersl/4041911 to your computer and use it in GitHub Desktop.
Groovy (java) escape HTML with grapes
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 | |
// Import with groovy grapes: | |
@Grab(group='commons-lang', module='commons-lang', version='2.3' ) | |
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