how to extract data from xml tags which have same tag name and add into one column.?

Highlighted
Six Stars

how to extract data from xml tags which have same tag name and add into one column.?

Hi.!

 

The input is 

<root> <root> <id>1</id> <FN>aa</FN> <roles>bb</roles> <roles>cc</roles> <roles>dd</roles> <roles>ee</roles> </root> </root>
 
but I need to get add the roles in the single column like this 
id  FN  roles
1  aa   bb,cc,ee,dd
 
Thanks in advance.!

Accepted Solutions
Community Manager

Re: how to extract data from xml tags which have same tag name and add into one column.?

Do you know how many roles elements you will have in your XML? If so you can get them using the following method.

 

Your XPath loop will be.....

"/root/root"

You can get the first "roles" value using this....

"roles[1]"

....the second using this....

"roles[2]"

....etc, etc...

 

You would then merge them together, maybe using a tMap

View solution in original post


All Replies
Community Manager

Re: how to extract data from xml tags which have same tag name and add into one column.?

Do you know how many roles elements you will have in your XML? If so you can get them using the following method.

 

Your XPath loop will be.....

"/root/root"

You can get the first "roles" value using this....

"roles[1]"

....the second using this....

"roles[2]"

....etc, etc...

 

You would then merge them together, maybe using a tMap

View solution in original post

Six Stars

Re: how to extract data from xml tags which have same tag name and add into one column.?

Thanks, @rhall_2_0  It worked...

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 2

Part 2 of a series on Context Variables

Blog

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