I have a XML file with my data in it. I want to populate the drop down options in a combobox with 2 of the fields in that xml file – FirstName and LastName.
In the xml document I am using GUID for the unique ID format, so the combobox dropdown would need the FirstName + LastName for each unique GUID variable.
What I have so far is the following:
XmlDocument xmlReturnDoc = new XmlDocument();
xmlReturnDoc.Load("Data.xml");
XmlNodeList firstname = xmlReturnDoc.GetElementsByTagName("FirstName");
XmlNodeList lastname = xmlReturnDoc.GetElementsByTagName("LastName");
StudentSelectStudentComboBox.Items.Add(firstname + lastname);
This does not work… Any help would be greatly appreciated.
Since you’ll probably have to do other stuff with the information later on, I would create a custom data storage class with all the required fields, then extract the information from the XML into a collection of those custom classes. To do the display, all you need to do is add the items to the list (or data bind, whichever you prefer), and override
ToStringon the custom class.