How to convert csv data to xml via VBA?

caoyan10

New Member
Joined
Nov 22, 2012
Messages
3
Thanks for help me. I am Simon from Dalian China, I like vba programming, but I am new. Now I have one requirement to convert data in csv file to xml file.

The data in CSV file as below:
Detail KeyBookable Rev ($K)Seller NameRoadmapBrandIOTIMTSector
12KY-1V1NSVB
5​
abcSSSTESTCHTTT
12KZ-FDXR7E
5​
bcdSSSTESTCHTTT
1JF-262SCZ2
4​
bcdNIRSTESTCHTTT
1JF-258QBIA
3.1​
bcdSSSTESTCHTTT

<tbody>
</tbody>

<?xml version="1.0" encoding="UTF-8" ?>
- <dataset xmlns="test" xmlns:atom="test">
- ******data>
<item name="Detail Key" type="xs:string" length="256" />
<item name="Bookable Rev " type="xs:int" />
<item name="Seller Name" type="xs:string" length="256" />
<item name="Roadmap" type="xs:string" length="256" />
<item name="Brand" type="xs:string" length="256" />
<item name="IOT" type="xs:string" length="256" />
<item name="IMT" type="xs:string" length="256" />
<item name="Sector" type="xs:string" length="256" />
*******data>
- <data>
- <row>
<value>12KY-1V1NSVB</value>
<value>5</value>
<value>abc</value>
<value>SS</value>
<value>S</value>
<value>TEST</value>
<value>CH</value>
<value>TTT</value>
</row>

<colgroup><col></colgroup><tbody>
</tbody>

Anyone can give me some advise? or sample code? Thanks a lot!!!
 
Last edited:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Sorry, the xml which I want like below:
<-?xml version="1.0" encoding="UTF-8" ?>
- <-dataset xmlns="test" xmlns:atom="test">
- <-metadata>
<-item name="Detail Key" type="xs:string" length="256" />
<-item name="Bookable Rev " type="xs:int" />
<-item name="Seller Name" type="xs:string" length="256" />
<-item name="Roadmap" type="xs:string" length="256" />
<-item name="Brand" type="xs:string" length="256" />
<-item name="IOT" type="xs:string" length="256" />
<-item name="IMT" type="xs:string" length="256" />
<-item name="Sector" type="xs:string" length="256" />
<-/metadata>

- <-data>
- <-row>
<-value>12KY-1V1NSVB <-/value>
<-value><value>5 </value> <-/value>
<-value><value>abc </value> <-/value>
<-value>SS <-/value>
<-value>S <-/value>
<-value>TEST <-/value>
<-value>CH <-/value>
<-value>TTT<-/value>
<-/row>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,413
Messages
6,119,374
Members
448,888
Latest member
Arle8907

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top