0
votes

We have a scenario where we need to concatenate all XML node values to String.

input XML

<root>
<Address>
  <line1>1</line1>
  <line2>2</line2>
  <line3>3</line3>
  <line4>4</line4>
</Address>
<PostCode>
  <line5>5<line5>
</PostCode>
</root>

Output to String

1 2 3 4 5

Please let me know how can i achieve in form of String.

Thanks in advance.

1

1 Answers

0
votes

This question is already answered here concatenate XML values using dataweave mule

Referring DataWeave Reference Documentation at Reduce section:

Transform

%dw 1.0
%output application/json
---
concat: ["a", "b", "c", "d"] reduce ($$ ++ $)

Output

{
 "concat": "abcd"
}

Therefore, you can try something like this: concat: payload.root.*line reduce ($$ ++ $)