Transform and Process xml as input and generate a standard xml with no null values

Five Stars

Transform and Process xml as input and generate a standard xml with no null values

Hi,

I have an xml which contains some tags empty ,i want to populate this empty tags(</city>) with some value like 'NNNNNNNNNNN' and generate an xml as output(<city>NNNNN</city>).I am using tadvancedxmloutput command and Talend open studio for big data, but i was able to loop only one sub element at a time,can some one help how to process this.

Below are my xml input and expected xml output format.

 

input xml :::::::::

<emp>
<id>985426</id>
<fname>jai</fname>
<lname>singh</lname>
<listofaddress>
<address>

<street>college street</street>
<city>bangalore</city>
<state>karnatka</state>
<datestayed>04-01-2015 - 07-08-2015</datestayed>
</address>
<address>

<street>pakala street</street>
<city>Hyd</city>
</state>
<datestayed>07-10-2015 - 10-08-2017</datestayed>
</address>

<address>
</street>
<city>chennai</city>
<state>TN</state>
<datestayed>10-08-2017</datestayed>
</address>

</listofaddress>

<Comments>
<Comment>
<Mgrcomment>skiled labor</Mgrcomment>
<employeecomment>satisfied work</employeecomment>
<leadcomment>hard worker</leadcomment>
<clientcomment>satisfied work</clientcomment>
<place>bangalore</place>
</Comment>

<Comment>
<Mgrcomment>excellent communications</Mgrcomment>
<employeecomment>hard worker</employeecomment>
<leadcomment>need to improve skill set</leadcomment>
</clientcomment>
<place>bangalore</place>
</Comment>


<Comment>
<Mgrcomment>keep going</Mgrcomment>
</employeecomment>
<leadcomment>keep moving</leadcomment>
</clientcomment>
<place>Hyd</place>
</Comment>
</Comments>
</emp>


expected output xml::::::::::

<emp>
<id>985426</id>
<fname>jai</fname>
<lname>singh</lname>
<listofaddress>
<address>

<street>college street</street>
<city>bangalore</city>
<state>karnatka</state>
<datestayed>04-01-2015 - 07-08-2015</datestayed>
</address>
<address>

<street>pakala street</street>
<city>Hyd</city>
<state>NNNNNNNNNNNNNNNNNNNNN</state>
<datestayed>07-10-2015 - 10-08-2017</datestayed>
</address>

<address>
<street></street>
<city>chennai</city>
<state>TN</state>
<datestayed>10-08-2017</datestayed>
</address>

</listofaddress>

<Comments>
<Comment>
<Mgrcomment>skiled labor</Mgrcomment>
<employeecomment>satisfied work</employeecomment>
<leadcomment>hard worker</leadcomment>
<clientcomment>satisfied work</clientcomment>
<place>bangalore</place>
</Comment>

<Comment>
<Mgrcomment>excellent communications</Mgrcomment>
<employeecomment>hard worker</employeecomment>
<leadcomment>need to improve skill set</leadcomment>
<clientcomment>NNNNNNNNNNNNNNNNNNNNN</clientcomment>
<place>bangalore</place>
</Comment>


<Comment>
<Mgrcomment>keep going</Mgrcomment>
<employeecomment>NNNNNNNNNNNNNNNNNNNNN</employeecomment>
<leadcomment>keep moving</leadcomment>
<clientcomment>NNNNNNNNNNNNNNNNNNNNN</clientcomment>
<place>Hyd</place>
</Comment>
</Comments>
</emp>

Tags (1)
Moderator

Re: Transform and Process xml as input and generate a standard xml with no null values

Hello,

Have you tried to check out 'append the source xml file' option in tAdvancedFileOutputXML component?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Definitive Guide to Data Quality

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

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads