AnsweredAssumed Answered

Count the elements that have same value

Question asked by gouthamr388096 on Aug 30, 2018
Latest reply on Aug 30, 2018 by britto.parthalomew

If I have an XML like this. I want to count all the Deliverymode's that have same value.

<XML>

<NameCollection>

<Name>.....<Name>

<Name>.....<Name>

</Namecollection>

<ContainerCollection>

<Container>

<DeliveryMode>33</DeliveryMode>

</Container>

<Container>

<DeliveryMode>24</DeliveryMode>

</Container>

<Container>

<DeliveryMode>33</DeliveryMode>

</Container>

</ContainerCollection>

</XML>

 

So after counting what I have to do is  in the destination side I need to repeat an element two times and the first occurance the count will be 2 (because deliverymode has two occurances with value 33) and the the second ovvurance the count will be one. I am struggling to figure out how to do this

 

For example my destination should be like this

 

<?xml version='1.0' encoding='ISO-8859-1'?>
<IFTMCSP>
<IFTMCSP.HEADER>
<anxs_interchange.header>
<anxe_syntax.version.number>2</anxe_syntax.version.number>

<IFTMCSP.HEADER>

<IFTMCSP.GROUP35>
<trsd_equipment.details>
<tred_equipment.qualifier>CN</tred_equipment.qualifier>
<tred_equipment.identification.number>42R1</tred_equipment.identification.number>
<tred_equipment.size.and.type.identification>42R1</tred_equipment.size.and.type.identification>
<tred_count>2</tred_equipment.supplier.coded>
</trsd_equipment.details>

</IFTMCSP.GROUP35>

<IFTMCSP.GROUP35>
<trsd_equipment.details>
<tred_equipment.qualifier>CN</tred_equipment.qualifier>
<tred_equipment.identification.number>42R1</tred_equipment.identification.number>
<tred_equipment.size.and.type.identification>42R1</tred_equipment.size.and.type.identification>
<tred_count>1</tred_equipment.supplier.coded>
</trsd_equipment.details>

</IFTMCSP.GROUP35>

 

Outcomes