Here is my xml file
|
I can get name by:
|
but how i set it alphabetically?
Thank you in advance! :)
|
|
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kirtan PatelPosted Aug 7, 2010, 3:02 PM
private void btnGetNameAndSort_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load("test.xml");
List<string> list = new List<string>();
foreach (XmlNode node in doc.ChildNodes)
{
if (node.Name == "phonebooklist")
{
foreach (XmlNode x in node.ChildNodes)
{
if (x.Name == "pbdata")
{
foreach (XmlNode y in x.ChildNodes)
{
if (y.Name == "name")
{
list.Add(y.InnerText);
}
}
}
}
}
}
list.Sort();
listBox1.DataSource = list;
}
Sam HobbsPosted Aug 7, 2010, 4:52 PM