Groovy web console

subscribe to the feed Subscribe
to this
site

read part of XML

Published 3 months ago by Ram with tags split xml
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import groovy.xml.XmlUtil 
def from = """<parent a="1">     <child1>val1</child1>      <child2>val2</child2>    </parent> """  
def to = """<parent a="1">        <child1>val3</child1>        <child2>val4</child2>      </parent>"""  
def fromxml = new XmlSlurper().parseText(from)  
def toxml = new XmlSlurper().parseText(to)    
toxml[0].children() << fromxml.children()  
println XmlUtil.serialize(toxml)