首页 > 解决方案 > 如何在 XML 中定义多次出现

问题描述

我正在尝试将 FedEx 集成到我的应用程序中。在一个模块中,我必须将一个元素定义为多次出现。请检查下面的图片 在此处输入图像描述

我需要如何定义 EVENTS 元素?我尝试了以下方法

1
<ON_DELIVER type="EVENTS"/>
2
<EVENTS>ON_DELIVER</EVENTS>
3
<EVENTS>[ON_DELIVER]</EVENTS>
4
<EVENTS>
  <ON_DELIVER>TRUE</ON_DELIVER>
</EVENTS>

我得到以下错误Element 'Events' is a simple type, so it must have no element information item [children] 我想知道如何用这 5 个值定义 EVENTS 元素。

标签: ruby-on-railsxmlxsdfedex

解决方案


下面的 XML 应该可以帮助您设置多个通知。一份给客户,一份给您的客户服务团队

<SpecialServicesRequested>
    <SpecialServiceTypes>EVENT_NOTIFICATION</SpecialServiceTypes>
    <EventNotificationDetail>
        <AggregationType>PER_SHIPMENT</AggregationType>
        <PersonalMessage>This is a notification sent by Fedex, for your order: XXXX-XXXX</PersonalMessage>
        <EventNotifications>
            <Role>RECIPIENT</Role>
            <Events>ON_SHIPMENT</Events>
            <Events>ON_EXCEPTION</Events>
            <Events>ON_ESTIMATED_DELIVERY</Events>
            <Events>ON_DELIVERY</Events>
            <NotificationDetail>
                <NotificationType>EMAIL</NotificationType>
                <EmailDetail>
                    <EmailAddress>XXXX@hotmail.com</EmailAddress>
                    <Name>Claire Pounder</Name>
                </EmailDetail>
                <Localization>
                    <LanguageCode>EN</LanguageCode>
                </Localization>
            </NotificationDetail>
            <FormatSpecification>
                <Type>HTML</Type>
            </FormatSpecification>
        </EventNotifications>
        <EventNotifications>
            <Role>SHIPPER</Role>
            <Events>ON_SHIPMENT</Events>
            <Events>ON_EXCEPTION</Events>
            <Events>ON_ESTIMATED_DELIVERY</Events>
            <Events>ON_DELIVERY</Events>
            <NotificationDetail>
                <NotificationType>EMAIL</NotificationType>
                <EmailDetail>
                    <EmailAddress>XXXX@YOUREMAIL.com</EmailAddress>
                    <Name>MANAGER Email</Name>
                </EmailDetail>
                <Localization>
                    <LanguageCode>EN</LanguageCode>
                </Localization>
            </NotificationDetail>
            <FormatSpecification>
                <Type>HTML</Type>
            </FormatSpecification>
        </EventNotifications>
    </EventNotificationDetail>
</SpecialServicesRequested>

推荐阅读