Link to home
Start Free TrialLog in
Avatar of nathanpz
nathanpz

asked on

Convert CSV to XML Using VB.NET Classes

I have a csv file with predefined column headers and a variable number of rows. I need to convert this file by code into an xml file that can be read into a DataSet via the ReadXml feature.

How do I go about this? XSLTransform or some other reader class?

Thanks.
Avatar of J_Mak
J_Mak

Hi nathanpz,

I'm glad that you were able to convert your xml file to a csv successfully from previous discussions. I guess I could see it coming that you were gonna want to convert it back to xml!!!!

Got two questions:

1. Can I have a look at your csv file?
2. How do you want it to look like in xml?

Cheers.
Avatar of nathanpz

ASKER

Hi J_Mak.
I'm building this thing in a pretty predictable way I guess! Just trying to get used to moving data around between applications.

The csv file will have the following column headers:

Class,Last Name,First Name,New Score, Previous Score, Level, Previous1, Previous2, Previous3, Date1,Date2,Date3,MaxScore,DateN

The XML file should turn out as follows:

<?xml version="1.0" standalone="yes" ?>
- <NewDataSet>
- <Students>
  <Class>1 - A</Class>
  <Last_x0020_Name>Brooks</Last_x0020_Name>
  <First_x0020_Name>Ben</First_x0020_Name>
  <New_x0020_Score>10</New_x0020_Score>
  <Previous_x0020_Score>7</Previous_x0020_Score>
  <Level>C</Level>
  <Previous1>3</Previous1>
  <Previous2>5</Previous2>
  <Previous3>7</Previous3>
  <Date1>02Jan2000</Date1>
  <Date2>04Jan2000</Date2>
  <Date3>09Jan2000</Date3>
  <MaxScore>20</MaxScore>
  <DateN>12Jan2000</DateN>
  </Students>
  </NewDataSet>

It's pretty much the exact reverse of what my XSLT currently does.



ASKER CERTIFIED SOLUTION
Avatar of J_Mak
J_Mak

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
Thanks J_Mak,

These links look great. I should be right from here.

Cheers.
Glad I could help