cancel
Showing results for 
Search instead for 
Did you mean: 

Converting Flat File data into XML

Former Member
0 Kudos

Hi Experts,

Consider the message type of the SENDER system and flat file data

<dt_sender>

<root>

<header1> 0..1

<f1>

<f2>

<f3>

<header2> 0..1

<f4>

<f5>

<f6>

<item> 1..unbounded

<f7>

<f8>

<f9>

<f10>

<f11>

<f12>

</item>

abc def ghi jkl mno pqr

123 123 123 123 123 123

456 456 456 456 456 456

how to convert the flat file data into following XML data. please note that each field value is separated by TAB delimeter...wht parameters shld b used

<root>

<Header1>

<f1>abc</f1>

<f2>def</f2>

<f3>ghi</f3>

</Header1>

<Header2>

<f4>jkl</f4>

<f5>mno</f5>

<f6>pqr</f6>

</Header1>

<item>

<f7>123</f7>

<f8>123</f8>

<f9>123</f9>

<f10>123</f10>

<f11>123</f11>

<f12>123</f12>

<f7>456</f7>

<f8>456</f8>

<f9>456</f9>

<f10>456</f10>

<f11>456</f11>

<f12>456</f12>

</item>

points will be given to the correct answers

Thanks in advance.

FAisal

Edited by: Abdul Faisal on Feb 29, 2008 5:53 AM

Accepted Solutions (0)

Answers (2)

Answers (2)

nisarkhan_n
Active Contributor
0 Kudos

Faisal,

When you read the multiple recordset strucutre file then each record in txt file should have an header from which you can identiy which segment it should go.. and you identiy it by using the keyfiledValue in file adapter

<root>

<header1> 0..1

<f1>

<f2>

<f3>

<header2> 0..1

<f4>

<f5>

<f6>

<item> 1..unbounded

<f7>

<f8>

<f9>

<f10>

<f11>

<f12>

</item>

for this input file

abc def ghi jkl mno pqr

123 123 123 123 123 123

456 456 456 456 456 456

abc def ghi can be read using the file adater to header 1 usinfg key field value, but using the same file adapter you cannt put GHI into header2.

else you should read whole row abc def ghi jkl mno pqr in single filed and write an UDF to split data to header1 and Header 2

similarly you have to take care for item records also

if your inout file is something like this

abc def ghi

jkl mno pqr

123 123 123 123 123 123

456 456 456 456 456 456

abc identifies to Header 1

JKL for Header 2 so on...

read the whole line in single field and write UDF to Split to header 1 and header 2 similary for item.

Former Member
0 Kudos

Hi,

Check with these

/people/karthiknarayan.kesavan2/blog/2007/08/22/file-content-conversion-for-multi-hierarchical-structure

/people/jeyakumar.muthu2/blog/2005/11/29/file-content-conversion-for-unequal-number-of-columns

/people/sukumar.natarajan/blog/2007/06/12/content-conversion-in-sender-file-adapter--2-new-useful-parameters

Regards

Seshagiri