1
votes

Below is my xml input:

<projects>
    <project>
        <name >project1</name> 
        <language>java</language> 
    </project>
    <project>
        <name>project2</name> 
        <language>mainframe</language>  
    </project>
</projects>

I want to convert this .xml to .csv file using data-mapper, but unfortunately it doesn't work.

Can anyone send me the sample flow xml for that? It is very important for my project now.

1
Show your full Mule Config xml and datamapper config with all you have tried - Anirban Sen Chowdhary
<flow name="flow1"> <file:inbound-endpoint path="c:\input" responseTimeout="10000" doc:name="File"/> <data-mapper:transform doc:name="DataMapper"/> <logger message="message.payload" level="INFO" doc:name="Logger"/> </flow> this is mule code - muledevlepoer07
You are missing the datamapper configuration. To create one, just click on the datamapper and follow the steps. HTH. - clare
I create datamapping but unable to create mapping - muledevlepoer07
What is the error you're getting? - clare

1 Answers

0
votes

This is a very simple requirement. You should select your sample XML file in the input section of the datamapper and define a user defined output of type CSV. Once you create a mapping, map the fields from XML (input) to CSV (output). The code would like as below.

//MEL
//START -> DO NOT REMOVE
output.__id = str2long(input.__id);
//END -> DO NOT REMOVE

output.name = input.name;
output.language = input.language;

You can now click on Preview button and run the preview with your sample XML file. Wasn't that easy? Try this and let me if any issues.