UnEscape Xml in Groovy -
i trying unescape xml in groovy :
<student><age value="20"></age></student>
to
<student><age value="20"></age></student>
but not able find library can accomplish this. tried using groovy.json.stringescapeutils.unescapejavascript
doesn't help.
there 1 library groovy.xml.xmlutil
has escapexml
method doesn't has unescape
method.
my purpose of usage use groovy script in elasticsearch v1.3.2 contains groovy-all-2.3.2.jar
any suggestions ?
here's trick using built-in xmlslurper class , no additional libraries:
value = "x & y < z" // wrap string in made tags create // well-enough-formed xml xmlslurper xml = "<foo>${value}</foo>" println xml root = new xmlslurper().parsetext(xml) root.tostring()
result: 'x & y < z'
Comments
Post a Comment