Forum Discussion

Mis3's avatar
Mis3
Frequent Contributor
3 years ago

Log.info a field in a XML response

I tried to retrieve a field in a  XML response.  Not sure how to do it because there is no tag to this field.

Below is the partial XML response.  

I like to output if the response contains the block flag ("<blocked/>").     If not blocked, this line would be missing.

Thanks.

 

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:getMsisdnDataResponse resultCode="0" message="success" xmlns:ns2="http://www.ptnumber.com/titan/sdm/soap/types">
<msisdnData msisdn="1113366121">
<basicImsi>130000011142</basicImsi>
</msisdnData>
<basicImsiData imsi="130000011142">
<blocked/>
<basicMsisdn>1113366121</basicMsisdn>
<serviceProfile>
<nam>csps</nam>
<transferOfSm>cs</transferOfSm>
<roamingProfileId>320</roamingProfileId>
<supplementaryServiceProfileId>520</supplementaryServiceProfileId>
...

...

1 Reply

  • Mis3's avatar
    Mis3
    Frequent Contributor

    I figured a way to do this:

    if (xmlResponse.contains('blocked/') ) 

    {  block_ind = "blocked"  }

     

    While this works, it is not elegance.  What if I have the same string in other part of the XML response for other purpose?

    Is there a better way to extract this parameter?