Need help with flat file mapping to XML

I must map a flat file that has the following format to a XML structure. I have made a template and the file is loading OK in the record so I have all my data in the pipeline. The file (an invoice) has 1 field per line instead of having many fields on 1 line. So for detail records, it goes like this :

301 0001
305 MMM651
310 Product description
325 5
335 2.39
301 0002
305 MMM652
310 Prod desc 2
325 10
335 4.35

My goal is to load this to an XML structure like this :



0001


000005


MMM651
Prodcut Description


23900




0002


000010


MMM652
Prod desc 2


43500


I’ve tried many LOOP, MAP combined with appendToRecordList to a temp records and/or directly to my XML structure but was not able to produce an output that was making sense. The best I could do was having the correct line detail structure but with the same data in each detail line :frowning:

I’m sure somebody in here has done something similar ?
Thanks for your help !