首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Mulesoft条件语句

Mulesoft条件语句
EN

Stack Overflow用户
提问于 2020-07-29 19:42:55
回答 1查看 65关注 0票数 0

我有一个XML,我想在Dataweave中检查一下,如果XML中存在一个<custom-attribute attribute-id="sscAccountid">0011x0000152nlyAAA</custom-attribute>标签,该怎么做?

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<order xmlns="http://www.demandware.com/xml/impex/order/2006-10-31" order-no="00001503">
        <order-date>2020-07-24T13:15:09.654Z</order-date>
        <created-by>storefront</created-by>
        <original-order-no>000015034</original-order-no>
        <customer>
            <customer-no>00000001</customer-no>
            <billing-address>
                <first-name>abc</first-name>
                <last-name>Chioda</last-name>
                <address1>via Venezia 55</address1>
                <phone>+444</phone>
            </billing-address>
        </customer>
        <custom-attributes>
            <custom-attribute attribute-id="Adyen_pspReference">882595596510490G</custom-attribute>
            <custom-attribute attribute-id="Adyen_value">29999</custom-attribute>
            <custom-attribute attribute-id="sscAccountid">0011x0000152nlyAAA</custom-attribute>
            <custom-attribute attribute-id="sscSyncResponseText">
                <value>Successfully Exported</value>
            </custom-attribute>
            <custom-attribute attribute-id="sscSyncStatus">exported</custom-attribute>
            <custom-attribute attribute-id="sscid">8011x00000QaOFwAAN</custom-attribute>
        </custom-attributes>
</order>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-29 21:18:25

我知道您想确认具有示例结构的XML有效负载是否具有属性id等于"sscAccountid“的order.custom-Attributes.custom属性元素。

代码语言:javascript
复制
%dw 2.0
output application/json
fun hasAccountId(x) =sizeOf(x.order.'custom-attributes'  filterObject ($.@'attribute-id' == "sscAccountid") ) > 0
---
hasAccountId(payload)

输入XML的输出:

代码语言:javascript
复制
true
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63152838

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档