XPath concat multiple nodes

Highlighted
One Star

XPath concat multiple nodes

I have the following xml as source.I need to concate the subEl1 and subEl2.

<item>
<element1>el1</element1>
<element2>el2</element2>
<element3>el3</element3>
<element4>
<subEl1>subel1a</subEl1>
<subEl2>subel2a</subEl2>
</element4>
<element4>
<subEl1>subel1b</subEl1>
<subEl2>subel2b</subEl2>
</element4>
</item>
The output should be "subel1a subel2a"
Highlighted
Community Manager

Re: XPath concat multiple nodes

Hi
Use a tFileInputXml to extract the records from the xml file and concate the two columns into one column on tMap, please see my screenshots.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Highlighted
One Star

Re: XPath concat multiple nodes

Thanks Shong.There are some case where the sub element occurence is more than two or in some with one.What will i do in this scenario?
<item>
<element1>el1</element1>
<element2>el2</element2>
<element3>el3</element3>
<element4>
<subEl1>subel1a</subEl1>
<subEl2>subel2a</subEl2>
<subEl3>subel3a</subEl3>
</element4>
<element4>
<subEl1>subel1b</subEl1>
<subEl2>subel2b</subEl2>
</element4>
<element4>
<subEl1>subel1b</subEl1>
</element4>
</item>
Highlighted
Community Manager

Re: XPath concat multiple nodes

Hi
You should extract all the fields from the xml file, that means you always extract the max number of fields, maybe some of fields could be empty in output because the element occurence is more than two or in some with one.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

2019 GARTNER 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

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog