Advanced XML output writing

One Star

Advanced XML output writing

Hello,
I have some problems to write data in an specific XML file format
I want to build a file from this row format
Column Type
channel_id (int)
program_id (int)
program (DomElement)

My output file should have this structure
<channels> (my root element)
<channel channel_id="1">
<program program_id="1">
<programdomcontent/>
</program>
<program program_id="2"/>
<programdomcontent/>
</program>
</channel>
<channel channel_id="2">
<program program_id="3"/>
<programdomcontent/>
</program>
<program program_id="4"/>
<programdomcontent/>
</program>
</channel>
</channels>


Currently I'm using a tJavaFlex with org.dom4j.Element to perform the xml build. I tried to use the tAdvancedFileOutputXML instead, with no success.
How can I transform my rows in the desired XML file format?
Can anyone help me or give me a lead ?

Best regards,
Max
One Star

Re: Advanced XML output writing

Hi
You may use tAdvancedFileOutputXml to format xml file.
Best regards!
Pedro
One Star

Re: Advanced XML output writing

Hi Pedro,
Thanks for your answer !
I tried your solution and added a second loop on program. The XML Output structure is here.
Now I've problem with the DomElement. I want my program column to be the program XML element.
With the current solution, my program column content is added as text ("<" and ">" are encoded as "<" and ">") and can not be parsed properly...
Regards,
Max
Highlighted
One Star

Re: Advanced XML output writing

Building on Pedro's example...set "loop element" (right-click) on program and "group" (right-click) on channel.

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