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