This is my code:
public void refresh_SID(string callsign) {
// zjistime si vsechny potrebne informace o danem letu
XmlNodeList lety = airplanes.SelectNodes("/vEsup/flights/LKPR/odlety/let");
XmlNodeList sids = airports.SelectNodes("/vEsup/config/airports/LKPR/sidstar/sids/sid");
XmlNodeList getQfu = airplanes.SelectNodes("/vEsup/airports/airport/");
MessageBox.Show(callsign);
foreach (XmlNode let in lety) {
if(let.Attributes.GetNamedItem("callsign").Value == callsign) {
string adep = let.Attributes.GetNamedItem("adep").Value;
foreach(XmlNode letiste in getQfu) {
if(adep == letiste.Attributes.GetNamedItem("icao").Value);
string qfu = letiste.Attributes.GetNamedItem("rwy").Value;
}
string depRunway = let.Attributes.GetNamedItem("deprwy").Value;
string type = let.Attributes.GetNamedItem("type").Value;
string exitpoint = let.Attributes.GetNamedItem("exitpoint").Value;
string rules = let.Attributes.GetNamedItem("rules").Value;
ComboBox sidRoute = new ComboBox();
Load_SID(depRunway, qfu, type, exitpoint, rules, sids, sidRoute);
}
}
}
Unfortunately, I can’t merge the two foreach loops in one, because in the second, I need to use the adep string I get in the first one, and I need the second to be a separate foreach loop as it has to check different part of the XML file. So now, when calling the Load_SID method, the qfu doesn’t exist. Any way to get it there?
You get error doesn’t exist because variable qfu is not in the scope when you invoke method Load_SID.
Try this: