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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TC

    #1

    .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


  • Cor Ligthert[MVP]

    #2
    Re: .csv File to .xml File in VB.Net using 2.0 Framework and .xsd

    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,



    To make it an xml file you do simple

    ds.WriteXML(pat h)

    Cor


    "TC" <getmyemails2@y ahoo.comschreef in bericht
    news:%23GRmCZir IHA.1872@TK2MSF TNGP04.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
    >

    Comment

    • TC

      #3
      Re: .csv File to .xml File in VB.Net using 2.0 Framework and .xsd

      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.nlwrote in message
      news:FA435949-0DB1-4A02-9E7D-54773230DFA4@mi crosoft.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,
      >

      >
      To make it an xml file you do simple
      >
      ds.WriteXML(pat h)
      >
      Cor
      >
      >
      "TC" <getmyemails2@y ahoo.comschreef in bericht
      news:%23GRmCZir IHA.1872@TK2MSF TNGP04.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
      >>
      >

      Comment

      • Lloyd Sheen

        #4
        Re: .csv File to .xml File in VB.Net using 2.0 Framework and .xsd


        "TC" <getmyemails2@y ahoo.comwrote in message
        news:OAu7byrrIH A.3804@TK2MSFTN GP02.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.nlwrote in message
        news:FA435949-0DB1-4A02-9E7D-54773230DFA4@mi crosoft.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(pa th)
        >>
        >Cor
        >>
        >>
        >"TC" <getmyemails2@y ahoo.comschreef in bericht
        >news:%23GRmCZi rIHA.1872@TK2MS FTNGP04.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

        Comment

        • =?Utf-8?B?U3VydHVyWg==?=

          #5
          Re: .csv File to .xml File in VB.Net using 2.0 Framework and .xsd

          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@y ahoo.comwrote in message
          news:OAu7byrrIH A.3804@TK2MSFTN GP02.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.nlwrote in message
          news:FA435949-0DB1-4A02-9E7D-54773230DFA4@mi crosoft.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,
          >

          >
          To make it an xml file you do simple
          >
          ds.WriteXML(pat h)
          >
          Cor
          >
          >
          "TC" <getmyemails2@y ahoo.comschreef in bericht
          news:%23GRmCZir IHA.1872@TK2MSF TNGP04.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
          >
          >

          Comment

          Working...