AnsweredAssumed Answered

Creating simple XML from a complex XML

Question asked by gouthamr388096 on Nov 13, 2017
Latest reply on Nov 14, 2017 by leif.jacobsen@dagrofa.dk

Hi,

I have an XML file coming over from FTP. This XML has multiple repeating segments (screenshots below). I do not see all elements from this XML, but only 6 elements. 2 elements from  E1EDL24 and one from E1EDL37 segment.

First Screenshot

The segment E1EDL24 segment when expanded looks like this

Second screenshot

Segment E1EDL37 when xpanded looks like this. I need VEMNG element that is under E1EDL44 segment.

Third screenshot

The XML I am looking for after I transform should look something like this

<?xml version='1.0' encoding='UTF-8'?>
<element>
   <SalesID>//1071-00000240</SalesID>  -- This is BSTNR element shown in second screenshot aboce.
   <Details>
      <LineDetails>
         <line_id>000001</line_id> -- This is the POSEX  element shown in third screenshot above.

         <quantity>1.000</quantity> -- This is VEMNG element in second screenshot
      </LineDetails>
      <LineDetails>
         <line_id>000002</line_id>

         <quantity>3.000</quantity>
      </LineDetails>
      <LineDetails>
         <line_id>000003</line_id>

         <quantity>3.000</quantity>
      </LineDetails>
</element>

When I try to transform I get something like this which is not what I want. If you notice, quantity from the one E1EDL44 segment is repeating. I need to get quantity from each E1EDL44 segment.

<?xml version='1.0' encoding='UTF-8'?>
<element>
<shipping_method>I4</shipping_method>
<ship_date>20171103</ship_date>
<SalesID>//1071-00000240</SalesID>
<element>
<LineDetails>
<quantity>1.000</quantity>
<line_id>000001</line_id>
</LineDetails>
<LineDetails>
<quantity>1.000</quantity>
<line_id>000002</line_id>
</LineDetails>
<LineDetails>
<quantity>1.000</quantity>
<line_id>000003</line_id>
</LineDetails>
</element>
</element>

Outcomes