I need to check if an element in XML file exists. After searching here, I have tried a code from one of very similiar questions I found here, so the code looks like this(it is looped using foreach so it checks every airport in group airports):
string icao = airport.Attributes.GetNamedItem("icao").Value;
if(airports.SelectSingleNode("/vEsup/airports/airport/" + icao + "/departures")==null)
{
MessageBox.Show("I exist!");
}
Please note that the message box is just for testing, I find it the easiest way to check if the code is working properly. However, I found out that whatever path I enter, it always shows the messagebox, regardless if it exist in the XML file or not.
You can use Linq to query specific xml nodes and attributes also.
Here is link to similar sample:
http://www.codearsenal.net/2012/07/c-sharp-load-xml-using-xlinq.html