Nils Olsson

Nils Olsson

  • NA
  • 16
  • 1.5k

How to get child node info from xml file

Mar 9 2018 5:28 AM
Hi,
 
I need some guidence to get some data out from an XML file using the query function in  LINQ to XML 
 
Here is my XML file structure
<data>
<ICAO id="CFS4">
<ICAOName>Ogilvie River</ICAOName>
<Country>Canada</Country>
<State>Yukon Territory</State>
<City>Ogilvie River</City>
<State>Alabama</State>
<Runway id="02">
<Hdg>12.000</Hdg>
<Lat>65.664040</Lat>
<Lon>-138.122025</Lon>
<FSStartLat>65.664124</FSStartLat>
<FSStartLon>-138.121826</FSStartLon>
</Runway>
<Runway id="20">
<Hdg>192.000</Hdg>
<Lat>65.669289</Lat>
<Lon>-138.111313</Lon>
<FSStartLat>65.669205</FSStartLat>
<FSStartLon>-138.111496</FSStartLon>
</Runway>
</ICAO>
</data>
 
There are thousand and thousands of ICAO nodes.
There are either a Runway node or none in a ICAO node.
There are from 2 to several Runway ids in a Runway node 
 
 I need to get a list of all Runway ids with its Hdg, Lat, Lon,FSStartLat and FSStartLon values for a specific ICAO id
 
I know how to open and query in general, but to get what I want I have so far not managed
 
How can this be done in the most effective way?
 

Answers (4)