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. Help importing XML data into forms

Help importing XML data into forms

Scheduled Pinned Locked Moved C#
xmlhelpquestiondatabase
2 Posts 2 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.
  • T Offline
    T Offline
    TheBlindWatchmaker
    wrote on last edited by
    #1

    Greetings! For an application I'm writing, I require to be able to save data to an XML file and, when necessary, be able to import that data into my forms. I have no problem in writing the data to an XML file. I also have rudimentary familiarity with XMLTextReader in that I can read the name of a node and its value. However, my question is this: What would be the best way to go through an existing XML file with a schema similar to that below and fill in values for Object0 to Object "n" in a form? A B C D E F ... etc < I was wondering if there was a better method than checking for each node name and then filling the appropriate box in the form with the node's value. What would be a recommended method for doing this? Thanks!

    C 1 Reply Last reply
    0
    • T TheBlindWatchmaker

      Greetings! For an application I'm writing, I require to be able to save data to an XML file and, when necessary, be able to import that data into my forms. I have no problem in writing the data to an XML file. I also have rudimentary familiarity with XMLTextReader in that I can read the name of a node and its value. However, my question is this: What would be the best way to go through an existing XML file with a schema similar to that below and fill in values for Object0 to Object "n" in a form? A B C D E F ... etc < I was wondering if there was a better method than checking for each node name and then filling the appropriate box in the form with the node's value. What would be a recommended method for doing this? Thanks!

      C Offline
      C Offline
      coolestCoder
      wrote on last edited by
      #2

      Hi, There are quite a number of options available. 1. Use of XmlSerializer- This would will be beneficial if some class data needs to be stored in XML Format. 2. If the XML document is "Well-Formed" then you can directly read the data from XML to a data set which then you can use to bind to some GUI control. I think the serialization option will be better for you. For that you will have to write a class for the data to be stored and those all data-types must be serializable. I think you must be using primary data types only. So that wont be a problem. After you write the class for the data to be stored, you will just need to call Serialize and Deserialize methods of the XmlSerializer class. Hope all class and method names are correct. If you want more information about XmlSerializer please check MSDN.


      "A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder


      coolestCoder

      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