473,385 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

.csv File to .xml File in VB.Net using 2.0 Framework and .xsd

TC
Hey All,

I've been searching for a code snippet, not a 3rd party tool, that takes a
..csv file and transforms it to an .xml file based upon an .xsd.

Can anyone point me in the right direction or provide a code snippet?

I would prefer vb.net but C# is fine too or even pseudo code with
appropriate .Net objects and example.

Thanks,

TC
Jun 27 '08 #1
4 4367
TC,

A CSV has no XSD, and there is not even a relatieon, how did you want to do
this, without a XSD it is simple,

http://www.vb-tips.com/dbpages.aspx?Search=csv

To make it an xml file you do simple

ds.WriteXML(path)

Cor
"TC" <ge**********@yahoo.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hey All,

I've been searching for a code snippet, not a 3rd party tool, that takes a
.csv file and transforms it to an .xml file based upon an .xsd.

Can anyone point me in the right direction or provide a code snippet?

I would prefer vb.net but C# is fine too or even pseudo code with
appropriate .Net objects and example.

Thanks,

TC
Jun 27 '08 #2
TC
Hey Cor,

I know that XSD has nothing to do with .csv ;-)

I meant applying the .xsd to the .xml file that was created from the .csv
file.

I also agree, that I need to go from .csv to dataset and then use the
ability to write the .xml file from there.

Thanks,

TC
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:FA**********************************@microsof t.com...
TC,

A CSV has no XSD, and there is not even a relatieon, how did you want to
do this, without a XSD it is simple,

http://www.vb-tips.com/dbpages.aspx?Search=csv

To make it an xml file you do simple

ds.WriteXML(path)

Cor
"TC" <ge**********@yahoo.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Hey All,

I've been searching for a code snippet, not a 3rd party tool, that takes
a .csv file and transforms it to an .xml file based upon an .xsd.

Can anyone point me in the right direction or provide a code snippet?

I would prefer vb.net but C# is fine too or even pseudo code with
appropriate .Net objects and example.

Thanks,

TC

Jun 27 '08 #3

"TC" <ge**********@yahoo.comwrote in message
news:OA**************@TK2MSFTNGP02.phx.gbl...
Hey Cor,

I know that XSD has nothing to do with .csv ;-)

I meant applying the .xsd to the .xml file that was created from the .csv
file.

I also agree, that I need to go from .csv to dataset and then use the
ability to write the .xml file from there.

Thanks,

TC
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:FA**********************************@microsof t.com...
>TC,

A CSV has no XSD, and there is not even a relatieon, how did you want to
do this, without a XSD it is simple,

http://www.vb-tips.com/dbpages.aspx?Search=csv

To make it an xml file you do simple

ds.WriteXML(path)

Cor
"TC" <ge**********@yahoo.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>Hey All,

I've been searching for a code snippet, not a 3rd party tool, that takes
a .csv file and transforms it to an .xml file based upon an .xsd.

Can anyone point me in the right direction or provide a code snippet?

I would prefer vb.net but C# is fine too or even pseudo code with
appropriate .Net objects and example.

Thanks,

TC

Ok first things first:

Create a dataset from a .csv

1. Create an ODBC datasource to the folder in which your .csv file exists
Open the ODBC Data Source Administrator
Either use User DSN or System DSN (I will use User)
Click Add
In the Select a driver - Select MS Access Text Driver(*.txt, *.csv)
Click Finish
Input a Data Source Name (and description if you want)
Now unclick "Use Current Directory" and use Select Directory to get
directory holding .csv
Go to options. This is where you can select what file extensions will
be used (if no .txt files just cancel)

2. Open VS if not already open
3. View/Server Explorer
4. Right click Data Connection and select Add Connection
5 Change DataSource to MS ODBC Data Source - OK
6. From dropdown of User/System data source choose your new source
created above
7. You now have a Data Connection to your .csv

8. Add New Item to project - Dataset (name it accordingly)
9. Open (click +) on your dataconnection (Server Explorer)
Open tables and you should see your .csv file
10. Drag it to the .xsd designer (if you have column names in the .csv you
will get column names in the dataset)

You now have a dataset which you can use

Hope this helps
Lloyd Sheen

Jun 27 '08 #4
Just use a filestream and parse the CSV into XML yourself, sheesh. It's not
that hard!
--
David Streeter
Synchrotech Software
Sydney Australia
"Lloyd Sheen" wrote:
>
"TC" <ge**********@yahoo.comwrote in message
news:OA**************@TK2MSFTNGP02.phx.gbl...
Hey Cor,

I know that XSD has nothing to do with .csv ;-)

I meant applying the .xsd to the .xml file that was created from the .csv
file.

I also agree, that I need to go from .csv to dataset and then use the
ability to write the .xml file from there.

Thanks,

TC
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:FA**********************************@microsof t.com...
TC,

A CSV has no XSD, and there is not even a relatieon, how did you want to
do this, without a XSD it is simple,

http://www.vb-tips.com/dbpages.aspx?Search=csv

To make it an xml file you do simple

ds.WriteXML(path)

Cor
"TC" <ge**********@yahoo.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hey All,

I've been searching for a code snippet, not a 3rd party tool, that takes
a .csv file and transforms it to an .xml file based upon an .xsd.

Can anyone point me in the right direction or provide a code snippet?

I would prefer vb.net but C# is fine too or even pseudo code with
appropriate .Net objects and example.

Thanks,

TC


Ok first things first:

Create a dataset from a .csv

1. Create an ODBC datasource to the folder in which your .csv file exists
Open the ODBC Data Source Administrator
Either use User DSN or System DSN (I will use User)
Click Add
In the Select a driver - Select MS Access Text Driver(*.txt, *.csv)
Click Finish
Input a Data Source Name (and description if you want)
Now unclick "Use Current Directory" and use Select Directory to get
directory holding .csv
Go to options. This is where you can select what file extensions will
be used (if no .txt files just cancel)

2. Open VS if not already open
3. View/Server Explorer
4. Right click Data Connection and select Add Connection
5 Change DataSource to MS ODBC Data Source - OK
6. From dropdown of User/System data source choose your new source
created above
7. You now have a Data Connection to your .csv

8. Add New Item to project - Dataset (name it accordingly)
9. Open (click +) on your dataconnection (Server Explorer)
Open tables and you should see your .csv file
10. Drag it to the .xsd designer (if you have column names in the .csv you
will get column names in the dataset)

You now have a dataset which you can use

Hope this helps
Lloyd Sheen

Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: santhosh_176 | last post by:
:I Created a Pocket PC application for iPAQ 5450. Every thing went fine even installer creation. I could run the setup and install it into the actual device and worked fine. The application enables...
3
by: Michael Bøcker-Larsen | last post by:
Hi I'v been stuck on this problem for ages now. I have found that I'm not the only one with this problem, by looking through the different newsgroups. Hope you can help me! I know there is a...
6
by: Thomas Connolly | last post by:
I have 2 pages referencing the same codebehind file in my project. Originally the pages referenced separate code behind files. Once I changed the reference to the same file, everything worked...
14
by: Al Smith | last post by:
I need help in implementing proper error handling. I am trying to upload a file based on the sample code below. The code works well except if the file selected is too big. I do know about the...
2
by: Anna | last post by:
I added a small Web.Config file to the root of my website so that I could view errors on a machine other than the server: <configuration> <system.web> <customErrors mode="Off" /> </system.web>...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
15
by: David Thielen | last post by:
Hi; My ASP.NET app (C# calling J# under .net 2.0) creates a png file in a subdirectory to display as part of the created page. However, the bitmap will not display due to a security violation. ...
3
by: Mike Kelly | last post by:
Hi. I've built a page using standard ASP.NET 2.0 features and when I upload a large file (>20MB) to our intranet server, I get a paltry 100KB/s on our 100Mb/s LAN. Simply copying the file, I get...
17
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: ...
7
by: =?Utf-8?B?QU9UWCBTYW4gQW50b25pbw==?= | last post by:
Hi, I have been using the code (some of it has been removed for simplicity) below to allow authenticated (using ASP.NET membership database) users to get a file from their archive area. It...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.