Ara :
HOME
ASP
PHP
JAVASCRIPT
C#
Add Code
Turkish
ASP Code Samples
PHP Code Samples
JavaScript Code Samples
C# Code Samples
C# Code Sample
C# Reading XML File and Addind to DropDownList
This code provides to read XML file and add to the Dropdownlist. This code read the "students.XML" file from local disk and this XML file contains students' information such as name, lastname, class, number.
string XMLFile = "D:\\students.xml"; XmlDocument xDoc = new XmlDocument(); xDoc.Load(XMLFile); XmlNodeList name = xDoc.GetElementsByTagName("name"); XmlNodeList lastname = xDoc.GetElementsByTagName("lastname"); XmlNodeList number = xDoc.GetEleme ntsByTagName("number"); XmlNodeList class = xDoc.GetElementsByTagName("class"); string student; for (int i = 0; i < name.Count; i++) { student = name[i].InnerText + " " + lastname[i].InnerText + " " + class[i].InnerText + " " + number[i].InnerText; DropDownListStudents.Items.Add(student); }
After reading all data, students' information adds to DropDownlist with for loop.
Added By : Administrator
Back to C# Code Samples
email :
info@kodornekleri.com