Add Element In XML(Loop)

Six Stars

Add Element In XML(Loop)

The Scenario here is i need to add some data in my xml:

Source:

<?xml version="1.0"?>
<BatchLvl>
<CustId>H2X</CustId>
<PrcId>NBL1</PrcId>
</BatchLvl>
<DocDet>
<Pages>
<Page>
<PageNo>1</PageNo>
<ImgFileName>abc</ImgFileName>
<ImgType>T1</ImgType>
</Page>
<Page>
<PageNo>2</PageNo>
<ImgFileName>abc2</ImgFileName>
<ImgType>T2</ImgType>
</Page>
<Page>
<PageNo>3</PageNo>
<ImgFileName>abc3</ImgFileName>
<ImgType>T1</ImgType>
</Page>
</Pages>
</DocDet>

 

The output Should be like:

 

<?xml version="1.0"?>
<BatchLvl>
<CustId>H2X</CustId>
<PrcId>NBL1</PrcId>
</BatchLvl>
<DocDet>
<Pages>
<Page>
<PageNo>1</PageNo>
<ImgFileName>abc</ImgFileName>
<ImgType>T1</ImgType>
</Page>
<Page>
<PageNo>2</PageNo>
<ImgFileName>abc2</ImgFileName>
<ImgType>T2</ImgType>
</Page>
<Page>
<PageNo>3</PageNo>
<ImgFileName>abc3</ImgFileName>
<ImgType>T1</ImgType>
</Page>
<Page>
<PageNo>4</PageNo>
<ImgFileName>StaticName</ImgFileName>
<ImgType>F</ImgType>
</Page>
</Pages>
</DocDet>

 

Anyone has any suggestion what approach should I follow in talend, I don't  want to use a  full fledged java code on this for now.

Six Stars

Re: Add Element In XML(Loop)

BUMP!

Fifteen Stars TRF
Fifteen Stars

Re: Add Element In XML(Loop)

Did you try to add the 4th line using a tFixedFlowInput as a lookup for a tXMLMap? 


TRF

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