cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert XML attributes to CSV format at receiver?

Former Member
0 Kudos

Hi,

I have sample xml file as below.

/*

<x>

<Sample a="1" b="2" c="3">

<sample1 a="1" b="2" c="3">123</sample1>

<sample1 a="1" b="2" c="3">123</sample1>

<sample1 a="1" b="2" c="3">123</sample1>

<sample1 a="1" b="2" c="3">123</sample1>

</Sample>

<Sample a="1" b="2" c="3">

<sample1 a="1" b="2" c="3">123</sample1>

<sample1 a="1" b="2" c="3">123</sample1>

<sample1 a="1" b="2" c="3">123</sample1>

<sample1 a="1" b="2" c="3">123</sample1>

</Sample>

<Sample a="1" b="2" c="3">

<sample1 a="1" b="2" c="3">123</sample1>

<sample1 a="1" b="2" c="3">123</sample1>

<sample1 a="1" b="2" c="3">123</sample1>

<sample1 a="1" b="2" c="3">123</sample1>

</Sample>

</x>*/

I need to convert it to csv format file.Can anyone help me on this?

in CSV format how each row will be present and how to handle the attributes in receiver FCC and the values for attributed elements?

Thanks,

Pachika.

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

good

Former Member
0 Kudos

Hi,

source structure---------------------->target structure
x--------------------------------------->y
    sample------------------------------->root1
    a(1)------------------------------------->attribute1
    b(2)------------------------------------->attribute2
    c(3)------------------------------------->attribute3
        sample1(123)------------------------->element1
         a(1)-------------------------------->attribute1.1
         b(2)-------------------------------->attribute1.2
         c(3)-------------------------------->attribute1.3

Everything specified under target are elements.

Former Member
0 Kudos

Hi Pachika,

I would'nt use FCC. Instead I would use a JAVA-Mapping.

Regards Mario

Former Member
0 Kudos

Can u send me the Sample code?

Thanks,

Pachika

santhosh_kumarv
Active Contributor
0 Kudos

Hi Sathya,

There is no need of doing a java mapping when this can be done using a simple graphical mapping as I said.

More you have to use the FCC even if your are going to use the Java mapping to convert the target XML toCSV file.

Thanks

SaNv...

Former Member
0 Kudos

Santhosh,

But I am unable to map the sample element value.

according to below example i am missing the value 123.

Can u suggest me how to do?

/*

<x>

<Sample a="1" b="2" c="3">

<sample1 a="1" b="2" c="3">123</sample1>

<sample1 a="1" b="2" c="3">123</sample1>

<sample1 a="1" b="2" c="3">123</sample1>

<sample1 a="1" b="2" c="3">123</sample1>

</Sample>

</x>

*/

Former Member
0 Kudos

Do u mean the sample1 value(123)?

Sample1 is a subelement of sample.right?

Then surely u can enter values for sample1 in test tab mapping it to an element in target structure.

former_member192295
Active Contributor
0 Kudos

Hi,

Follow below configuration at receiver end

1. Fill DocumentName, document namespace, recordset name, recordset Structure( std,*) on receiver channel

std.fieldFiexdlengths = 1,1,1

std.filedNames = a,b,c

std.filedSeparator = ,

std.endSeparator = 'nl'

ignoreRecordsetNames = 'true

check with above configuration at receiver end, it will work

santhosh_kumarv
Active Contributor
0 Kudos

Hi,

I suggest you to have a mapping to first convert the attribute to the field and then use the FCC at the receiver side.

1. Design the source structure that can hold the required attributes the target structure should have only element fields.

2. Map the attribute field of the source to the element field of the target this makes all the attributes as an element in the target payload.

3. Now use the FCC to convert this payload to a flat csv file.

Thanks

SaNv...

Former Member
0 Kudos

Hi,

Try this.

Recordset Structure: sample,sample1

sample.fieldSeparator: ,

sample.endSeparator:'nl'

sample1.fieldSeparator:,

sample1.endSeparator:'nl'

Regards,

Prakasu