I deserialized an xml file in order to perform some treatment and write results in an other xml file,
Deserialization :
XmlSerializer deserializer = new XmlSerializer(typeof(Network));
TextReader reader = new StreamReader(@"path\XmlFile.xml");
object obj = deserializer.Deserialize(reader);
Network XmlData = (Network)obj;
reader.Close();
I got "ROUTES" elements of my xml in a list
Some content of the "ROUTES" list
Now I want to browse this list to compare a string that is given on the command line (OriginSignal) to the value of the child element "ENTRANCESIGNAL" of each "ROUTE" element of the list
I tried this :
string OriginSignal = null;
Console.WriteLine("");
OriginSignal = Console.ReadLine();
foreach (var route in XmlData.ROUTES)
{
if (OriginSignal.Equals(XmlData.ROUTES[].ENTRANCESIGNAL))
{
Console.WriteLine(XmlData.ROUTES[].ID);
}
}
Console.ReadLine();
I don't know what to put in ROUTES[] as index.
I tried with XmlData.ROUTES[route] but I'm getting an error Argument 1: cannot convert from 'XmlData.ROUTES' to 'int'
I'm a beginner in c# programming, so I would like to have some help to implement this