Splitting XML

In this example, XML that contains multiple purchase orders is split into individual orders.

This pipeline effectively handles the XML content transformation and parsing.

<po:PurchaseOrders xmlns:po="http://www.example.com">
   <po:PurchaseOrder po:PurchaseOrderNumber="23578" po:OrderDate="2015-01-20">
     <po:Address po:Type="Shipping">
       <po:Name>Full Name</po:Name>
       <po:Street>123 Maple Street</po:Street>
       <po:City>City Name</po:City>
       <po:State>CA</po:State>
       <po:Zip>10101</po:Zip>
       <po:Country>USA</po:Country>
     </po:Address>
     <po:Address po:Type="Billing">
       <po:Name>Another Name</po:Name>
       <po:Street>456 Oak Avenue</po:Street>
       <po:City>Town Name</po:City>
       <po:State>NJ</po:State>
       <po:Zip>99999</po:Zip>
       <po:Country>USA</po:Country>
     </po:Address>
     <po:DeliveryNotes>Please leave packages on side porch.</po:DeliveryNotes>po
     <po:Items>
        <po:Item po:PartNumber="123456">
          <po:ProductName>Product</po:ProductName>
          <po:Quantity>1</po:Quantity>
          <po:USPrice>89.90</po:USPrice>
          <po:Comment>Refurbished</po:Comment>
        </po:Item>
     </po:Items>
   </po:PurchaseOrder>
   <po:PurchaseOrder po:PurchaseOrderNumber="23579" po:OrderDate="2015-01-20">
   ...
   </po:PurchaseOrder>
</po:PurchaseOrders>

Each PurchaseOrder contains the shipping address, billing address and the items purchased.

To split these into individual orders, the Splitter field should contain the hierarchy down to where you want the split to occur, including any specified prefix. In this case, the value is: po:PurchaseOrders/po:PurchaseOrder.

You will also need to specify the Namespace Context, which is defined in the sample as xmlns:po="http://www.example.com".

This will result in separating the orders into individual documents.

 [{, ...}, {, ...}, {, ...}] 
         {po:PurchaseOrder:{, ...}} 
         {po:PurchaseOrder:{, ...}} 
         {po:PurchaseOrder:{, ...}} 
To successfully reuse pipelines:
  1. Download and import the pipeline in to the SnapLogic Platform.
  2. Configure Snap accounts, as applicable.
  3. Provide pipeline parameters, as applicable.