Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to read and write to xml using dataset [modified]

how to read and write to xml using dataset [modified]

Scheduled Pinned Locked Moved C#
questiontutorialxmlannouncementworkspace
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xiaowenjie
    wrote on last edited by
    #1

    hi, how do i read and write date from/to xml file? my xml looks like this (it's basically the app config):

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <appSettings>
    <add key="Setting1" value="Very" />
    <add key="Setting2" value="Easy" />
    </appSettings>
    </configuration>

    for example i found that to read date from xml,i can do this:

    DataSet myDS = new DataSet();
    myDS.ReadXml(@"C:\appconfig.xml", XmlReadMode.ReadSchema);

    Similarly, how can I write to xml using dataset

    modified on Thursday, March 4, 2010 7:07 PM

    S S 2 Replies Last reply
    0
    • X xiaowenjie

      hi, how do i read and write date from/to xml file? my xml looks like this (it's basically the app config):

      <?xml version="1.0" encoding="utf-8" ?>
      <configuration>
      <appSettings>
      <add key="Setting1" value="Very" />
      <add key="Setting2" value="Easy" />
      </appSettings>
      </configuration>

      for example i found that to read date from xml,i can do this:

      DataSet myDS = new DataSet();
      myDS.ReadXml(@"C:\appconfig.xml", XmlReadMode.ReadSchema);

      Similarly, how can I write to xml using dataset

      modified on Thursday, March 4, 2010 7:07 PM

      S Offline
      S Offline
      snorkie
      wrote on last edited by
      #2

      Dude, A quick Google Search[^] would have led you to the First Search Result.[^] The code from the website is

      System.IO.StreamWriter xmlSW = new System.IO.StreamWriter("Customers.xml");
      custDS.WriteXml(xmlSW, XmlWriteMode.WriteSchema);
      xmlSW.Close();

      I'm not trying to pick on you with all of the links. I am just trying to show that a little searching would give you the answer you need right away. Instead, you had to wait almost 4 hours for me to reply. Good luck writing out your data! Hogan

      X 1 Reply Last reply
      0
      • X xiaowenjie

        hi, how do i read and write date from/to xml file? my xml looks like this (it's basically the app config):

        <?xml version="1.0" encoding="utf-8" ?>
        <configuration>
        <appSettings>
        <add key="Setting1" value="Very" />
        <add key="Setting2" value="Easy" />
        </appSettings>
        </configuration>

        for example i found that to read date from xml,i can do this:

        DataSet myDS = new DataSet();
        myDS.ReadXml(@"C:\appconfig.xml", XmlReadMode.ReadSchema);

        Similarly, how can I write to xml using dataset

        modified on Thursday, March 4, 2010 7:07 PM

        S Offline
        S Offline
        shawnzhang
        wrote on last edited by
        #3

        ds.WriteXml(fileName);

        1 Reply Last reply
        0
        • S snorkie

          Dude, A quick Google Search[^] would have led you to the First Search Result.[^] The code from the website is

          System.IO.StreamWriter xmlSW = new System.IO.StreamWriter("Customers.xml");
          custDS.WriteXml(xmlSW, XmlWriteMode.WriteSchema);
          xmlSW.Close();

          I'm not trying to pick on you with all of the links. I am just trying to show that a little searching would give you the answer you need right away. Instead, you had to wait almost 4 hours for me to reply. Good luck writing out your data! Hogan

          X Offline
          X Offline
          xiaowenjie
          wrote on last edited by
          #4

          hi, tks for the reply but i noe how to read with your code given. what i'm looking for is how do you proceed after that? with my given xml, how do i get the value of the key and its value. for example:

          <add key="Setting1" value="Very" />

          how do you get the value of Setting1; and how do you update this value. similarly how do you create new element and value with dataset. i tried using the dataset table but im pretty much lost as it provide null value.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups