Here is my xml file
Code |
I can get name by:
Code |
but how i set it alphabetically?
Thank you in advance! :)
Code |
Code |
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kirtan PatelRank #292 · 8.6K reputationPosted Aug 7, 2010, 11:02 AM EDT
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 HobbsRank #107 · 20.5K reputationPosted Aug 7, 2010, 12:52 PM EDT