I have a requirement where there is a XML structure with a root element having 2 child element of array type and Sample request structure like below
<Root>
  <Header>
     <Inv>12</Inv>
  </Header>
  <Detail>
     <Val>aa</Val>
     <Line>1</Line>
  </Detail>
  <Header>
     <Inv>15</Inv>
  </Header>
  <Detail>
     <Val>bb</Val>
     <Line>2</Line>
  </Detail>
</Root>
I have to get response like below:
<CreateInvoice>
  <Data>
    <Invoice>
      <Inv>12</Inv>
      <InvoiceLine>
         <Val>aa</Val>
         <Line>1</Line>
      </InvoiceLine>
    </Invoice>
  </Data>
  <Data>
    <Invoice>
      <Inv>15</Inv>
      <InvoiceLine>
         <Val>bb</Val>
         <Line>2</Line>
      </InvoiceLine>
    </Invoice>
  </Data>
</CreateInvoice>
I tried using nested for-each on Data , but not able to get the response. Either only inv is populating or InvoiceLine is populating.