Search code examples
muledataweaveanypoint-studiomulesoft

Update value after loading xml file


i am loading the following xml file using the readUrl command

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <a>
         <b>xyz</b>
         <c>
            <d>false</d>
            <e>false</e>
            <f>true</f>
         </c>
      </a>
   </soapenv:Body>
</soapenv:Envelope>

in the same dataweave as the readUrl command - i would like to update the xml e value from false to true

can someone please assist

cheers,

jonny


Solution

  • Using the update operator available in Mule 4.3.0 can be used to update the value as required:

    %dw 2.0
    output application/xml
    ns soapenv http://schemas.xmlsoap.org/soap/envelope/
    var soapMessage=readUrl("...","application/xml")
    ---
    soapMessage update {
            case .soapenv#Envelope.soapenv#Body.a.c.e -> true
    }