开发者

Groovy How can change an XmlParser to an xml format?

开发者 https://www.devze.com 2023-01-20 07:34 出处:网络
HI, I\'ve used XmlParser to can change the attributes of some nodes in my xml f开发者_如何学Goile.

HI, I've used XmlParser to can change the attributes of some nodes in my xml f开发者_如何学Goile.

Some code:

def temp = groovyUtils.getXmlHolder( "testAddress CUY#ResponseAsXML") 
def aux = temp.getXml();
def lang = new XmlParser().parseText(aux)
lang.prov[0].description[0].setValue('newDesciption')

After doing that I have something like

" root[attributes={}; value=[a[attributes={}; value=[1]], b[attributes={}; value=[ ]], c[attributes={}; value=[2]]]]" 

How can I make it again to be an xml? Thanks!


def out = new StringWriter()
new XmlNodePrinter(new PrintWriter(out)).print(lang)
def xml = out.toString()
0

精彩评论

暂无评论...
验证码 换一张
取 消