如何在XML中定义多次出现

时间:2019-01-22 03:56:30

标签: ruby-on-rails xml xsd fedex

我正在尝试将FedEx集成到我的应用程序中。在一个模块中,我必须将一个元素定义为多次出现。请检查下图 enter image description here

我如何定义事件元素? 我尝试了以下方法

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元素。

1 个答案:

答案 0 :(得分:0)

下面的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>