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>
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>
What is your question?
ASKER
I need to convert the above CSV file to XML in VB.Net, need help with the coding. Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
Thanks a lot. Works very well.
ASKER
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.
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?
ASKER
Sorry, yes I am new..