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

mysql - FireDac error 314 - but DLLs are in program directory -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -

java - How can I send the data from a imput type="file" to the controller? -