I have an xml file and its content is as follows. I want to add the information of the flights in this file to the datagridview. The columns I will create in the datagridview are
flight_id, flight_description, flight_date, instructor_num, instructor_name, student_num, student_name
<?xml version="1.0" encoding="utf-8"?>
<Simulator>
<Flight ID="1" Description="sunny" Date="2022-09-09">
<Instructor Num="6">
<Name>matt</Name>
<Surname>matt</Surname>
<Rank>matt</Rank>
</Instructor>
<Student Num="66">
<Name>matt</Name>
<Surname>matt</Surname>
<Rank>matt</Rank>
</Student>
<Operator Num="666">
<Name>matt</Name>
<Surname>matt</Surname>
<Rank>matt</Rank>
</Operator>
<Technician Num="6666">
<Name>matt</Name>
<Surname>matt</Surname>
<Rank>matt</Rank>
</Technician>
<ErrorLOGS>
<Logs Hour_Date="2022-09-09T09:12:00" ID="1">
<ErrorGUI>checkbox</ErrorGUI>
<ErrorType>high</ErrorType>
<ProgramPage>Failures</ProgramPage>
<ErrorStartTime>PT9H12M23S</ErrorStartTime>
</Logs>
<Logs Hour_Date="2022-09-09T09:12:00" ID="1">
<ErrorGUI>checkbox</ErrorGUI>
<ErrorType>high</ErrorType>
<ProgramPage>Page</ProgramPage>
<ErrorStartTime>PT9H12M23S</ErrorStartTime>
</Logs>
</ErrorLOGS>
</Flight>
<Flight ID="2" Description="test flight">
.................like flight1.........
</Flight>
</Simulator>
I tried something like this but failed
string inputpath = Application.StartupPath + "\\Data.xml";
XmlDocument doc = new XmlDocument();
doc.LoadXml(inputpath);
IEnumerable<string> names = doc.Root.Descendants("Flight").Select(e => e.Attribute("ID") , e.Attribute("Description"), e.Attribute("Date")).Value);