0
votes


New to Mule4 and have a question. I am posting a simple xml file using postman

<cust>
  <act>1234</act>
</cust>

In my flow I have
Listener->TransformMessage->logger
Inside TransformMessage I have the following:
Added a new target called f1 as variable

%dw 2.0
output application/java
var myXML = payload
---
{
    f1: myXML.cust.act
}

And in the logger I am printing the value using #[vars.f1] and the output I am getting is {f1=1234} which is right.
So my question is how can I only get the value “1234” out of it? Reason is let says I want to use this in a query, for example

Select name, address from account where accountNumber = ':vars.f1'
Thanks

1

1 Answers

3
votes

The problem is that you are wrapping the result in an object with a field f1

%dw 2.0
output application/java
var myXML = payload
---
{
    f1: myXML.cust.act
}

So what you should do is just return the value like

%dw 2.0
output application/java
var myXML = payload
---
myXML.cust.act