i was wondring if you could help me with this, i'm trying to load a combobox with elements from an XML file.
the problem is that the code i'm using only loads the first element.
my xml files has the following...
so my ComboBox only shows the first name element and the first url element...any help will be great...thanks
XmlDocument doc = new XmlDocument();
darkred]doc.Load("ComboItemName.xml");
XmlNodeList Nodes = doc.GetElementsByTagName("NAME");
foreach (XmlNode node in Nodes)
{
NewNameLoad = node.InnerText.ToString();
}
XmlNodeList NodesA = doc.GetElementsByTagName("URL");
foreach (XmlNode node in NodesA)
{
NewUrlLoad = node.InnerText.ToString();
}
comboChannels.Items.Add(new RSSChannel(NewNameLoad, NewUrlLoad));
// And select the first one
comboChannels.SelectedIndex = 0;
Mike GoldPosted Jul 12, 2007, 3:15 PM
It only looks like you are loading 1 element because your Items.Add for your combobox is outside the loop