1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| public void loadCombo()
{
comboBoxS.Items.Clear();
XmlDocument doc = new XmlDocument();
//loading our XML file
doc.Load("LERL_RCL_Trackinfo.xml");
//selecting the node that our data (CRS) is at
XmlNodeList nodeList = doc.SelectNodes("LERL_RCL_Trackinfo/Station");
//for each node in our selected node list, we will add the CRS item to our ComboBox
// but only if it has not already been added.
foreach (XmlNode node in nodeList)
{
int CRS_length = node.SelectSingleNode("CRS").InnerText.Length;
if (!comboBoxS.Items.Contains(node.SelectSingleNode("CRS").InnerText))
{
if (CRS_length == 3)
{
comboBoxS.Items.Add(node.SelectSingleNode("CRS").InnerText);
}
}
}
} |
Partager