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 &amp; y &lt; 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

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -