Reputation: 93
<payloadFactory media-type="xml" description="Select Sheets">
<format>
<Response>$1</Response>
</format>
<args>
<arg evaluator="xml" expression="get-property('name')"/>
</args>
</payloadFactory>
<script language="js"><![CDATA[var csv = mc.getPayloadXML();
var lines = (csv + "").split("\n");
for (var l = 1; l <= lines.length; l++) {
cells = (lines[l] + "").split(";");
}
]]></script>
I am trying to get the data from excel through esb option, and i am getting the output also but not properly getting. Please guide me to do. Retrieving the data From multiple excel sheets or multiple excel files are working from that retrieved data i formed csv. From the csv i need to form multiple xml then need to insert into db. How to form csv to multiple xml?
suppose some sheets containing 3 columns,4 columns or 5 columns. Depends on that need to form child node of xml.
Please let me know
Upvotes: 1
Views: 415
Reputation: 549
You can use Data-mapper mediator to construct a xml payload using the csv file. Please refer the examples related to CSV and XML transformations.
For example, you can create a xml payload depending on the number of columns in csv sheet.
<rows>
<row>
<col1>value1</col1>
<col2>value2</col2>
<col3>value3</col3>
</row>
<row>
<col1>value4</col1>
<col2>value5</col2>
<col3>value6</col3>
</row>
</rows>
Once you have created the xml payload, you can use Iterate mediator or ForEach mediator to iterate through each sub xml element (i.e. elements start with 'row' tag) for a given xpath (eg: xpath="//row"), and execute db queries for each sub element.
If you are using a data service to execute insert queries, you can use the Iterate mediator, which calls the data service for each xml sub element. Else, you can use ForEach mediator along with DBReport mediator to execute insert queries for each xml sub element.
Upvotes: 1