How to convert data in Excel to XML

339 Views Asked by At

My requirement is as follows

I want to convert below data in Excel to XML in this format.

Last Name Sales Country Quarter

Smith $16,753.00 UK Qtr 3

Johnson $14,808.00 USA Qtr 4

Williams $10,644.00 UK Qtr 2

<data-set>
<record1>
   <LastName>Smith</LastName>
   <Sales>16753</Sales>
</record1>
<record2>
   <Country>USA</Country>
   <Quarter>Qtr 4</Quarter>
 </record2>
 <record1>
   <LastName>johnson</LastName>
   <Sales>14808</Sales>
</record1>
<record2>
   <Country>USA</Country>
   <Quarter>Qtr 4</Quarter>
</record2>
</data-set>

I have tried with Developer-XML Source but it says its not exportable, I have data in the sequence only, i.e record1 tag has 2 columns then record2 has another 2 , Please help

1

There are 1 best solutions below

4
On

Read this tutorial HERE

Tutorial has really easy and basic example which will help you to achieve your goal. You have to read cell and set data based on sequence you mentioned in your question

try {
  XmlGenner x = XMLGennerSingleton.getXmlGenner();
  x.setCustomRows(1000);
  x.setSubRootElementName("Student");
  x.setProgressBar(jProgressBar1);
  x.generateXML_Item("c:/temp/in.xls", "c:/temp/out.xml");

} catch (Exception ex) {

}