cancel
Showing results for 
Search instead for 
Did you mean: 

XML split in pipeline

Sahil
Contributor

I have a scenario where main xml needs to be splitted into multiple xmls.

Main xml:-

<?xml version="1.0" encoding="UTF-8"?>
<Order>
  <Main>
    <Version>2.1</Version>
    <SenderID>55544566</SenderID>
  </Main>
  <Data>
    <OrderNumber>564434555</OrderNumber>
    <OrderDate>2021-07-15</OrderDate>
    <CurrencyCode>eur</CurrencyCode>
  </Data>
  <Lines>
    <Line>
      <OrderLineNumber>10</OrderLineNumber>
      <VendorOrderLineNumber>10000</VendorOrderLineNumber>
      <VendorPartNumber>66554</VendorPartNumber>
   </Line>
	<Line>
      <OrderLineNumber>20</OrderLineNumber>
      <VendorOrderLineNumber>20000</VendorOrderLineNumber>
      <VendorPartNumber>6775</VendorPartNumber>
    </Line>
  </Lines>
</Order>

Split xml 1:-

<?xml version="1.0" encoding="UTF-8"?>
<Order>
  <Main>
    <Version>2.1</Version>
    <SenderID>55544566</SenderID>
  </Main>
  <Data>
    <OrderNumber>564434555</OrderNumber>
    <OrderDate>2021-07-15</OrderDate>
    <CurrencyCode>eur</CurrencyCode>
  </Data>
  <Lines>
    <Line>
      <OrderLineNumber>10</OrderLineNumber>
      <VendorOrderLineNumber>10000</VendorOrderLineNumber>
      <VendorPartNumber>66554</VendorPartNumber>
   </Line>
  </Lines>
</Order>

split xml 2:-

<?xml version="1.0" encoding="UTF-8"?>
<Order>
  <Main>
    <Version>2.1</Version>
    <SenderID>55544566</SenderID>
  </Main>
  <Data>
    <OrderNumber>564434555</OrderNumber>
    <OrderDate>2021-07-15</OrderDate>
    <CurrencyCode>eur</CurrencyCode>
  </Data>
  <Lines>
    <Line>
      <OrderLineNumber>20</OrderLineNumber>
      <VendorOrderLineNumber>20000</VendorOrderLineNumber>
      <VendorPartNumber>6775</VendorPartNumber>
    </Line>
  </Lines>
</Order>

how do I achieve it?

1 ACCEPTED SOLUTION

viktor_n
Contributor II

Try this one. Now even if it’s only one Line it will work.
Split_XML_Parent_2021_08_01.slp (13.0 KB)

Child pipeline is the same as above.

Regards,
Viktor

View solution in original post

10 REPLIES 10

Supratim
Contributor III

@Sahil you can try the attached pipeline. You have to replace input xml mapper with File reader and binary to document snap. and change input value xml_multi_content to $content in add identify tag mapper snap.

test_2021_07_28.slp (9.8 KB)

Hi, I realized that xml were not correctly formatted.
I have edited my question.

Supratim
Contributor III

@Sahil Even now also you can use same pipeline, only replace your xml with my xml.

Hi @Supratim ,
It did not work. please look at the xml mentioned in the question.
Main and Data segment need to be kept in split xmls.