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

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 


0
5/4/2008 8:34:16 PM
dotnet.xml 7266 articles. 0 followers. Follow

4 Replies
1068 Views

Similar Articles

[PageSpeed] 15

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" <getmyemails2@yahoo.com> schreef in bericht 
news:%23GRmCZirIHA.1872@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
> 

0
5/5/2008 5:17:42 AM
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]" <notmyfirstname@planet.nl> wrote in message 
news:FA435949-0DB1-4A02-9E7D-54773230DFA4@microsoft.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" <getmyemails2@yahoo.com> schreef in bericht 
> news:%23GRmCZirIHA.1872@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
>>
> 


0
5/5/2008 2:30:34 PM
"TC" <getmyemails2@yahoo.com> wrote in message 
news:OAu7byrrIHA.3804@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]" <notmyfirstname@planet.nl> wrote in message 
> news:FA435949-0DB1-4A02-9E7D-54773230DFA4@microsoft.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" <getmyemails2@yahoo.com> schreef in bericht 
>> news:%23GRmCZirIHA.1872@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 

0
Lloyd
5/5/2008 4:05:11 PM
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" <getmyemails2@yahoo.com> wrote in message 
> news:OAu7byrrIHA.3804@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]" <notmyfirstname@planet.nl> wrote in message 
> > news:FA435949-0DB1-4A02-9E7D-54773230DFA4@microsoft.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" <getmyemails2@yahoo.com> schreef in bericht 
> >> news:%23GRmCZirIHA.1872@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 
> 
> 
0
surturz (1)
5/6/2008 2:28:02 AM
Reply:

Similar Artilces:

Major bug in Outlook 2K(SP3)? Puts emails into the Junk E-Mail folder randomly?! #2
My Junk Sender list is empty and "move to Junk E-Mail folder" is tuned off!. Nevertheless, from time to time (once in a few days), Outlooks puts one legitimate email into the Junk E-Mail folder! It is an old problem that existed ever since I installed the original version and throughout all 3 SPs- 1, 2 & 3 upgrades. If I would not see it with my own eyes, it would be hard to believe it. I am using W2K+SP4. Any knowledgeable hint is appreciated. Thanks, David ...

PST file locaion under Win7
Hi, Where does outlook 2007 keeps PST files under windows7? Apparently under Users/myname there is no folder AppData\Local... Thank you for your help. ...

Formula without using numbers after decimal in the answer
I have a formula that derives the answer from a figure with a decimal. I don't want to use the figures after the decimal. Is there a way to just use the whole number and omit the numbers after the decimal without having to manually key in all these numbers manually? Thanks, Mustang You can use the INT function. This 'rounds down' any number to th nearest integer, e.g. if A1=2.567, a formula in B2 of =INT(A1) return 2 HTH Bruc -- swatsp0 ----------------------------------------------------------------------- swatsp0p's Profile: http://www.excelforum.com/member.php?...

Linking files 2 ways
I have a work book that is linked to another and vise versa. As thus: Workbook A is where the input of data is made; Workbook B has a link to the input from workbook A; Workbook A retrieves the altered data back as a link. Although this all works fine with both books open, I note that if I open workbook A by itself, that the data it retrieves from Workbook B is not updated . If However, both books are open, there's no problem. I thought linked books were updated automatically if the Update remote references has been selected?? But it appears that the second book is not updated until it ...

How to repair a .dll file in IE8
Several days ago I noticed in my Dependency Walker that the IESHIMS.dll files has a yellow circle with a question mark on it. What does this mean and How do I repair it? OS: Windows Vista Home Premium Browser Internet Explorer 8 -- TW Hi, See the History tab on that dialog. A web search for ieshims.dll files will also help you find a solution for that file. Regards. "TW" <TW@discussions.microsoft.com> wrote in message news:63E61463-D766-4ABC-B081-BFA8C04FB159@microsoft.com... > Several days ago I noticed in my Dependency Walker that the IESHIMS....

OL2007 not move big files from outbox to sent
Hi, We have 2 computers with separate email accounts on Roadrunner. One machine has XP with Outlook 2002-sp3 and works without any problems. The other has Outlook 2007 on Vista and has problems sending files over a meg or so in size. It seems to actually send the file but the file remains in the outbox folder and does not move it to the sent folder. I say it "seems" to send the file because some people complain of getting muliple copies and others don't seem to get them at all. If I hit send again (not set up for auto send) it seems to send the file again (why some ...

Using Relative path for XML data file?
Is there a way to specify a relative path to an XML data file imported into Excel 2003? I am writing a web app that generates report data as XML for the user to download to their local machine. This data is to be consumed by an Excel reporting spreadsheet, which contains display-formatted tables and charts that are mapped to various data fields in an XML Map, which is in turn linked to the xml data file they will download. The idea is the user only needs to download the data for updates, not the whole spreadsheet. However, since I cannot predict the path where the user will store their...

unsolicited entry in the folder "Temporary Internet Files"
Hello, I am working on a programme which browses web sites and runs under XP. The http download is as follows: pServer = Isession -> GetHttpConnection(strServerName, nPort); pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET, strObject, NULL, 1, NULL, NULL, dwHttpRequestFlags); pFile->SendRequest(); pFile->QueryInfoStatusCode(dwStatusCode); if(dwStatusCode == 200) { pFile -> QueryInfo(HTTP_QUERY_LAST_MODIFIED, &sysT); status.lastMod = sysT; if(DBlastMod == status.lastMod) //URL content has not changed since the last visit ...

Maximum file sizes
Is there a recommended maximum file size for Excel 2000. PC spec 2Ghz P4 with 256 Mb Any advice appreciated Deus -------------- Does Not Exist Hi have a look at http://www.decisionmodels.com/memlimits.htm -- Regards Frank Kabel Frankfurt, Germany "Deus DNE" <deus.dne@ntlworld.com> schrieb im Newsbeitrag news:1561701c41d4f$358950f0$a001280a@phx.gbl... > Is there a recommended maximum file size for Excel 2000. > > PC spec 2Ghz P4 with 256 Mb > > Any advice appreciated > > Deus > -------------- > Does Not Exist ...

Microsoft CRM 3.0 Installation 11-08-07
Good Day board, Quick and to the point. I'm installing a trial copy of Microsoft CRM 3.0 that I got at a computer conference recently and I've gotten everything to work in the System Requirements dialog except that it's telling me that "The minimum required version is SQL Server 2000 SP4 (8.0.2026)". Strange this is that I do believe that I have SQL Server 2005 installed on the machine. Any idea how to be absolutely sure of what version I have installed? Have you choosed the right name of SQL server during installation set- up?` You have to make it sure if it is ...

More Columns #2
I am using all columns through IV on one of my worksheets. Does anyone know how to get more columns? Hi stacy know way using Excel. this is the maximum! -- Regards Frank Kabel Frankfurt, Germany Stacy Haskins wrote: > I am using all columns through IV on one of my > worksheets. Does anyone know how to get more columns? As Frank said, that's the maximum cols But maybe you could try transposing your table / data ? (Excel has a lot more rows than columns) If so, try: http://tinyurl.com/2nmyy for an example on using TRANSPOSE() For a one-time Tranpose: Copy > Paste Specia...

File size #11
I have read the other discussions on file sizes but they do not seem to address my problem. I have an Excel file that is 12mb large with low-res jpegs in it. This file also has merged cells to make it look pretty. Does Excel look at these merged cells as graphics? Is this why they are too big? I have run a macro to make sure that it goes to the last cell. How can I get the file smaller? How big are the graphics? If you remove them from the file, what is the size of the file and what is the size of the graphic files? To be sure you do not have extra formatting, if you open the file...

find action on log file
Hello there I want to use outside tool to find who made some update on table in my server I know that there are many tools for this. But can they do it on simple recovery model? Roy Goldhammer (royg@yahoo.com) writes: > I want to use outside tool to find who made some update on table in my > server > > I know that there are many tools for this. But can they do it on simple > recovery model? No. If you are using the simple recovery model, the contents of the log is wasted away everyonce in a while. Well, if the disk area has not been overwritten...

using the journal on outlook
Once I link an email to the journal, can I still find that email in my mail box? I seem to be able to get to it only via the journal. If this is the way it is supposed to be, how do I remove it from the journal and get it back into my mail box? Am I just missing something? -- thanks, Independent Are you linking to the item or putting a copy into the journal item? Also, has the item been archived or not? "Independent" <Independent@discussions.microsoft.com> wrote in message news:868279F2-53C8-403A-97F5-604CEECD873C@microsoft.com... > Once I link an email to the journ...

Offline Synchronization Problem #2
I get the following error when I try going offline. The excelption is taken from Event Viewer of the Client Machine. Event Type: Error Event Source: MSCRMOfflineSync Event Category: None Event ID: 6000 Date: 3/25/2008 Time: 5:03:33 PM User: N/A Computer: WINXP Description: An error occurred during Offline Synchronization. Try going offline again, or restart Microsoft Outlook. saInsert failed for entity 'ActivityMimeAttachment', batchRows=0 with exception System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument li...

CSV Files and VLOOKUP error
Does anyone know why VLOOKUP and Compare formulas don't work o information originating from a CSV file? I've tried copying an pasting values only (to leave behind any formatting), but it doesn' help. Through countless tests, I've narrowed it down to the CSV file bein the only possible cause -- Message posted from http://www.ExcelForum.com Hi ajpowers, Just a guess but the imported data may have leading or trailing spaces or are numbers stored as text. You could use the formula =A1=D1 to see if you get a true or false, where A1 is the lookup value and D1 ia the CVS valu...

Contacts in Exchange #2
We are running Exchange 2003 and Outlook 2003. I have tried to give a user rights to her boss's contacts through delegation and setting the rights on the contacts folder, however, while she has the rights she is unable to add or see her boss's contact folder in her Outlook. She can see it if she runs a search, but can not permanently put it in her list of contact folders. IS there a way that I can accomplish this through the back-end? Thanks, Joseph rapoport jrapoport@insurmark.net ...

How to automate increasing the form cache registry/file etc...
I want to roll out a batch file to make a number of tweaks to CRM The body of it would go REGEDIT /S Kerberosefix.reg REGEDIT /S ForceFormreload.reg REGEDIT /S OutlookFix.reg It would also rename OSA.exe to OSA.bad Remove OSA.exe From the startup menu I need help finding a way to use my batch file to increase the Outlook Form cache from the default 4MB to 50 MB.. This makes CRm more stable and faster for communications. I dont want to manually do this, as it time consuming, are my end users would not be reliable in doing it themselves. I also want to make another batch file or button that...

Goal Seek #2
Can anyone tell me a little about goal seek? Hi basically it's used to change an input variable so that the result of the formula equals what you want it to ... say i have the following A B C 1 10 20 =A1+B1 now C1 will give me 30, but if i want to know what B1 will need to be if i want C1 to show 50, i can use goal seek Set C1 to value of 50 by changing B1 Hope this helps Cheers JulieD "Jamie Hart" <jhart@emaple.net> wrote in message news:u3OscELdEHA.244@TK2MSFTNGP12.phx.gbl... > Can a...

How do I Remove a Split from my Comments in Excel 2003? #2
I have set my current workbook to split/freeze the first column and first 2 rows. Now, when I add a comment to the second row (in any column) my comments are cut off if I should scroll down. I don't ever remember the behavior before. And I don't know what I've done to enable it but it's really annoying. How do turn this off ? ...

Disable Secure Sockets Layer on exchange server when using RPC over HTTP
Hi im trying to enable RPC over HTTP to enable users to establish contact to my Excahger server 2003 over the internet. Now, I dont want to use SSL (security not that important) and i am told by this article that i can disable SSL in windows registry. Quote: Note While RPC over HTTP does not require Secure Sockets Layer, you must modify the registry to enable RPC over HTTP if you do not want to use Secure Sockets Layer. Microsoft recommends that you enable and require Secure Sockets Layer for your RPC over HTTP communications. At this address: http://support.microsoft.com/?id=833401 But i ...

Does Outlook use the DAV protocol?
I'm an Outlook Express user who wants to switch to Outlook. I received a notice from Microsoft that includes the following: "... as of June 30, 2008, Microsoft is disabling the DAV protocol and you will no longer be able to access your Hotmail Inbox via Outlook Express." Please tell me if this action by Microsoft will affect Outlook in the same manner, or am I free to make the switch. "BudV" <BudVitoff@(NO)att.(SPAM)net> wrote in message news:%230XUDi%23zIHA.2384@TK2MSFTNGP02.phx.gbl... > I'm an Outlook Express user who wants to switch to Outlook...

number format with leading 0
Dose anyone know how to create a number format that would show a leading zero for the numbers 0-9. That is, so that 1 would show as 01. I can do with a text format but would like to retain the integrity of the number. Thanks Try this: Format>Cells>Number Category: Custom Type: 00 Click [OK] Does that help? *********** Regards, Ron "Darby" wrote: > Dose anyone know how to create a number format that would show a leading zero > for the numbers 0-9. That is, so that 1 would show as 01. I can do with a > text format but would like to retain the integrity...

Increment A2 from A1 and A2 Sum #2
I have two cells: A1 - manual value B1 - automatic increment = B1 + A1 How can i make it? (=error: circular reference) Note: I have this formula repeated in some lines: = B2 + A2 = B3 + A3 .. -- Message posted from http://www.ExcelForum.com ...

Let me use the Line Color icon on charts
It would speed up a lot of my work if I could use the Line Color icon on Excel charts, the same way I am able to use the Fill Color and Font Color icons. However, when I highlight any chart object, like the Plot Area, Chart Area, or a Series, the Line Color icon is disabled. -- Stuart Bratesman, Jr., MPP Muskie School of Public Service Univ. of Southern Maine Portland, Maine ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If ...