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.

  • Data Integration
2 REPLIES
Six Stars

Re: Add Element In XML(Loop)

BUMP!

Seven Stars TRF
Seven 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