Groovy web console

subscribe to the feed Subscribe
to this
site
processXML (via #groovywebconsole)
tweet this snippet Tweet
this
script

processXML

Published 3 months ago by Ram with tags xml parser
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
 String str = '''<ParameterCrossReference><ListOfItems><Item><DocumentType>InvoiceDetailRequest</DocumentType><HeaderTextID></HeaderTextID><DefaultLang>En</DefaultLang><PortName>SAPQ8J</PortName><LSEnabled>X</LSEnabled><HeaderTextIDMM></HeaderTextIDMM><LineTextID></LineTextID><ArchiveAttachment>true</ArchiveAttachment></Item><Item><DocumentType>OrderConfirmationApprovalRequest</DocumentType><HeaderTextID>F15</HeaderTextID><LineTextID>F04</LineTextID><DefaultLang>en</DefaultLang></Item></ListOfItems></ParameterCrossReference>''' 
def parser = new XmlSlurper(false, false)    
def anCrossRefXML = parser.parse(new ByteArrayInputStream(str.getBytes()));
String anArchiveAttribute = anCrossRefXML.ListOfItems.Item.find { node -> node.@DocumentType = 'InvoiceDetailRequest'}.ArchiveAttachment.text();