You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

How to convert an csv to xml with headers grouped together?

edited Jan 23, 2019 11:27PM in Integration 1 comment

Summary

csv,groupping

Content

Hi all, 

I have a requirement to convert a csv to xml, but need to group the headers together into parent node.

Could anyone guide me how to do that? The default mapper do not support the group function.

This is a generic requirement and following is an example csv:

InvoiceNumber,InvoiceStatus,LineSeq,Item,Total
10001 ,approved ,1,ITM01,10
10001 ,approved ,2,ITM02,10
10002 ,approved ,1,ITM03,30
10002 ,approved ,2,ITM04,40

After transformation, I want to get following xml:

<Invoices>
  <Invoice>
    <Header>
      <InvoiceNumber>10001</InvoiceNumber>
      <InvoiceStatus>approved</InvoiceStatus>
      <Lines>
        <Line>
          <LineSeq>1</LineSeq>
          <Item>ITM01</Item>
          <Total>10</Total>
      </Line>
      <Line>
          <LineSeq>2</LineSeq>
          <Item>ITM02</Item>
          <Total>20</Total>

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!