How to count the number of xml tags in tXMLMAP and calculate the sum

One Star

How to count the number of xml tags in tXMLMAP and calculate the sum

Hello,
I have an input XML file to a tXMLMAP, I have two outputs from the tXMLMAP component.
I defined two loops, one on <t1> and the other one on <TL> (as illustrated in the example below).
The loop works fine, one line per <t1> in table1 and one line per <TL> in table2.
In table1 i want to have a column containing the number of <TL> tags and an other column containing the sum of all the <TL> values, how can I do that in tXMLMAP?
with the data below, i would like to have in Table1:
t1, t2, 2,5
t3, t4, 1,4
and Table2:
t1, t2, tl1, 2
t1, t2, tl2, 3
t3, t4, tl1, 5
<root>
    <T>
       <t1>t1</t1>
       <t2>t2</t2>
       <TL service="tl1">2</TL>
       <TL service="tl2">3<tl>
    </T>
    <T>
       <t1>t3</t1>
       <t2>t4</t2>
       <TL service="tl1">4</TL>
     </T>
</root>
Best regards.
Sidi
Seventeen Stars

Re: How to count the number of xml tags in tXMLMAP and calculate the sum

You cannot calculate sums in the tXMLMap. You can only provide an output flow and components like tAggregateRow to calculate sums/counts etc.

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch