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

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

15TH OCTOBER, COUNTY HALL, LONDON

Join us at the Community Lounge.

Register Now

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

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read