Nilotpol Nilotpol - 1 year ago 215
Groovy Question

Groovy - Parse SOAP response XML to get data

I have the below value as text. I need to parse the XML and get the value for each of them. Please suggest how to do in Groovy

<soapenv:Envelope xmlns:soapenv="" xmlns:xsd="" xmlns:xsi="">
<ns0:GetListBy_QualificationResponse xmlns:ns0="urn:WS_CTM_People_ICEVA">

Answer Source

Assuming your xml is in a String in the variable xml, then you can do:

def mapOfValues = new XmlSlurper().parseText(xml)
                                  .getListValues.children().collectEntries {
    [, it.text()]

Which makes mapOfValues equal to a Map containing:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download