Concat XML loop attributes (byte array) to a string?

Highlighted
Four Stars

Concat XML loop attributes (byte array) to a string?

I have a byte array in XML that looks like this:

            <tsusip>
                <id>2</id>
                <id>123</id>
                <id>39</id>
                <id>-98</id>
                <id>0</id>
                <id>0</id>
                <id>3</id>
                <id>-24</id>
                <id>32</id>
                <id>69</id>
                <id>32</id>
                <id>32</id>
            </tsusip>

Is it possible to concatenate the whole byte array in order to store it in one column in a database?
The result could either be the face value concatenated with a delimiter like '2,123,39...' or translated HEX form like '027B27...' .

Tags (1)

Accepted Solutions
Fifteen Stars TRF
Fifteen Stars

Re: Concat XML loop attributes (byte array) to a string?

Use tFileInputXML to get the values:

Capture.PNG

Then use a tJavaRow to load a global variable:

output_row.value = input_row.value;
globalMap.put("result", ((String)globalMap.get("result")) == null ? input_row.value : ((String)globalMap.get("result"))+","+input_row.value);
System.out.println((String)globalMap.get("result"));

Here is the result:

2,123,39,-98,0,0,3,-24,32,69,32,32

Hope this helps.


TRF

All Replies
Fifteen Stars TRF
Fifteen Stars

Re: Concat XML loop attributes (byte array) to a string?

Use tFileInputXML to get the values:

Capture.PNG

Then use a tJavaRow to load a global variable:

output_row.value = input_row.value;
globalMap.put("result", ((String)globalMap.get("result")) == null ? input_row.value : ((String)globalMap.get("result"))+","+input_row.value);
System.out.println((String)globalMap.get("result"));

Here is the result:

2,123,39,-98,0,0,3,-24,32,69,32,32

Hope this helps.


TRF

Cloud Free Trial

Try Talend Cloud free for 30 days.

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.