Search code examples
dictionaryconcatenationbiztalkbiztalk-mapper

How to Concatenate multiple repetitive nodes into a single node - BizTalk


I have something like this in an input XML

  <OrderText>
    <text_type>0012</text_type>
    <text_content>Text1</text_content>
  </OrderText>
  <OrderText>
    <text_type>ZT03</text_type>
    <text_content>Text2</text_content>
  </OrderText>

The above data I need to map after concatenating as the below schema

<Order>
    <Note>0012:Text1#ZT03:Text2</Note>
</Order>

Can anyone please help?


Solution

  • I'm going to assume that your input actually has a Root node, as otherwise it is not valid XML.

    <Root>
     <OrderText>
        <text_type>0012</text_type>
        <text_content>Text1</text_content>
      </OrderText>
      <OrderText>
        <text_type>ZT03</text_type>
        <text_content>Text2</text_content>
      </OrderText>
    </Root>
    

    Then all you need is a map like this

    Map Image

    With a String Concatenate functoid with

    Input[0] = text_type
    Input[1] = :
    Input[2] = text_content
    Input[3] = #
    

    That goes into a Cumulative Concatenate

    This will give you an output of

    <Order>
      <Note>0012:Text1#ZT03:Text2#</Note> 
    </Order>
    

    Note: There is a extra # at the end, but you could use some more functoids to trim that off if needed.