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.
How do I go about this? XSLTransform or some other reader class?
Thanks.
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</L ast_x0020_ Name>
<First_x0020_Name>Ben</Fir st_x0020_N ame>
<New_x0020_Score>10</New_x 0020_Score >
<Previous_x0020_Score>7</P revious_x0 020_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.
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
The XML file should turn out as follows:
<?xml version="1.0" standalone="yes" ?>
- <NewDataSet>
- <Students>
<Class>1 - A</Class>
<Last_x0020_Name>Brooks</L
<First_x0020_Name>Ben</Fir
<New_x0020_Score>10</New_x
<Previous_x0020_Score>7</P
<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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks J_Mak,
These links look great. I should be right from here.
Cheers.
These links look great. I should be right from here.
Cheers.
Glad I could help
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.