从下面的XML中获取"0011x000014VegoAAC“的正确Dataweave表达式是什么?
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order order-no="00000907" xmlns="http://www.demandware.com/xml/impex/order/2006-10-31">
<order-date>2020-07-10T08:57:05.076Z</order-date>
<current-order-no>00000907</current-order-no>
<product-lineitems>
<product-lineitem>
<net-price>54.17</net-price>
</product-lineitem>
</product-lineitems>
<custom-attributes>
<custom-attribute attribute-id="Adyen_pspReference">852594371442812G</custom-attribute>
<custom-attribute attribute-id="Adyen_value">7099</custom-attribute>
<custom-attribute attribute-id="sscAccountid">0011x000014VegoAAC</custom-attribute>
</custom-attributes>
</order>发布于 2020-07-10 23:09:07
Custom-attribute看起来像标准标记。将它封装到引号中,它就会工作得很好。custom-attribute是一个在DW转换中用星号表示的数组。从这个数组(第19行创建它)中,我们过滤属性(由@character表示)等于sscAccountId的所有项。
结果是只有一个元素的数组。
%dw 2.0
var payload =read('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order order-no="00000907" xmlns="http://www.demandware.com/xml/impex/order/2006-10-31">
<order-date>2020-07-10T08:57:05.076Z</order-date>
<current-order-no>00000907</current-order-no>
<product-lineitems>
<product-lineitem>
<net-price>54.17</net-price>
</product-lineitem>
</product-lineitems>
<custom-attributes>
<custom-attribute attribute-id="Adyen_pspReference">852594371442812G</custom-attribute>
<custom-attribute attribute-id="Adyen_value">7099</custom-attribute>
<custom-attribute attribute-id="sscAccountid">0011x000014VegoAAC</custom-attribute>
</custom-attributes>
</order>','application/xml')
output application/json
---
(payload.order."custom-attributes".*"custom-attribute")
filter (item) -> (item.@"attribute-id" ~= "sscAccountid")

https://stackoverflow.com/questions/62836472
复制相似问题