使用 dataweave mule 连接 XML 具有不同标签名称的值

concatenate XML values with different tag names using dataweave mule

我们有一个场景需要将所有 XML 个节点值连接到字符串。

输入XML

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

输出到字符串

1 2 3 4 5

请告诉我如何以字符串形式实现。

提前致谢。

这里已经回答了这个问题

Reduce 部分引用 DataWeave Reference Documentation

变换

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

输出

{
 "concat": "abcd"
}

因此,您可以这样尝试:concat: payload.root.*line reduce ($$ ++ $)