I have a XML structured like this:
<airports>
<airport code="code">
Airport name
<location>Airport location</location>
</airport>
...
</airports>
And I am trying to parse its code and name:
List<string> list = new List<string>();
XmlDocument xDoc = new XmlDocument();
xDoc.Load("file.xml");
foreach (XmlNode node in xDoc.GetElementsByTagName("airport"))
{
list.Add(node.Attributes["code"] + " " + node.Value);
}
But instead of the value I am not getting anything. When debugging, it says, the value of the node in null. Yet, I can see the text in .InnerText. Can you tell me, where is the problem and how can I get the value?