velkropie

velkropie

  • NA
  • 22
  • 0

populating a ComboBox from an XML file

Jul 12 2007 10:45 AM
Hello,

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...


<ITEMS> 
<NAME></NAME> 
<NAME></NAME> 
<URL></URL> 
<URL></URL> 
</ITEMS> 







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;

Answers (1)