Groovy web console

subscribe to the feed Subscribe
to this
site

read xml part from xml file

Published 3 months ago by Ram with tags read xml part
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import groovy.xml.XmlUtil 
def data = '''<Combined><source><ARBCIG_ORDERS><IDOC BEGIN="1"><E1EDS01 SEGMENT="1"><SUMID>002</SUMID><SUMME>300</SUMME><SUNIT>EUR</SUNIT></E1EDS01></IDOC></ARBCIG_ORDERS></source><target><cXML payloadID="AF0SEt8TWJ3u5Bj9javJtqcXzvtS" timestamp="2019-06-25T21:01:01Z"><Header><From><Credential domain="NetworkID"><Identity>AN02004405968-T</Identity></Credential><Credential domain="EndPointID"><Identity>CIG</Identity></Credential></From></Header></cXML></target></Combined> '''

def combinedPayload= new XmlSlurper().parseText(data);

def sourcePayload= combinedPayload.target

def val = XmlUtil.serialize(sourcePayload)