how to get the xml under a specific node in groovy -
i want sub tree under <container> node xml variable. looked on gpathresult. coudn't find way that.
<shiporder orderid="889923" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="shiporder.xsd"> <orderperson>john smith</orderperson> <container> <item> <title>empire burlesque</title> <note>special edition</note> <quantity>1</quantity> <price>10.90</price> </item> </container> </shiporder> output xml should be
def xml= <item> <title>empire burlesque</title> <note>special edition</note> <quantity>1</quantity> <price>10.90</price> </item> can point me right direction?
something like:
import groovy.xml.xmlutil def mainxml = ''' <shiporder orderid="889923" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="shiporder.xsd"> <orderperson>john smith</orderperson> <container> <item> <title>empire burlesque</title> <note>special edition</note> <quantity>1</quantity> <price>10.90</price> </item> </container> </shiporder> ''' def slurper = new xmlslurper().parsetext(mainxml) xmlutil.serialize(slurper.container.item)
Comments
Post a Comment