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

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -