[英]concatenate XML values using dataweave mule
We have a scenario where we need to concatenate all XML node values to String.我们有一个场景,需要将所有 XML 节点值连接到字符串。
input XML输入 XML
<root>
<line>1</line>
<line>2</line>
<line>3</line>
<line>4</line>
</root>
Output to String输出到字符串
1234 1234
Please let me know how can i achieve in form of String.请让我知道如何以字符串的形式实现。
Thanks in advance.提前致谢。
Referring DataWeave Reference Documentation at Reduce section:在Reduce部分引用DataWeave 参考文档:
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 ($$ ++ $)
因此,您可以尝试这样的操作:
concat: payload.root.*line reduce ($$ ++ $)
Try with this:试试这个:
%dw 2.0
output application/json
---
{
result: payload.root.*line reduce ((item ,acc="") -> acc ++ item)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.