Link to home
Start Free TrialLog in
Avatar of Monaglit
Monaglit

asked on

CSV to XML in VB.Net

The CSV file can have multiple records in it. The first row will contain the column headers for each column. The XML should contain an auto-generated row ID for each record in the CSV file.
For example :
Input CSV file
COL1,COL2,COL3
AAA,BBB,CCC
XXX,YYY,ZZZ
The resultant XML file should be
<Records filepath=C:\input.csv>
        <Record RowID=1>
                <COL1>AAA</COL1>
                <COL2>BBB</COL2>
                <COL3>CCC</COL3>
        </Record>
        <Record RowID=2>
                <COL1>XXX</COL1>
                <COL2>YYY</COL2>
                <COL3>ZZZ</COL3>
        </Record>
<Records>
Avatar of kaufmed
kaufmed
Flag of United States of America image

What is your question?
Avatar of Monaglit
Monaglit

ASKER

I need to convert the above CSV file to XML in VB.Net, need help with the coding. Thanks.
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You don't have to use the HasFieldsEnclosedInQuotes = True option if your CSV doesn't have such fields; you didn't specify, so I left in to be safe.
Thanks a lot. Works very well.
I've requested that this question be closed as follows:

Accepted answer: 0 points for Monaglit's comment http:/Q_27410156.html#37011622

for the following reason:

Exactly what I was looking for. Works just right.
I'm confused. You selected your own comment as the answer?
Sorry, yes I am new..