Given the following XML:
<Student number=2020 >
<Subject>Comp<Subject>
<Credintials>
<Password>....</Password>
</Credintials>
<PersonalDetails age=30 height=2/>
</Student>
I want to get:
Student
@number
Subject
Credintials
Password
PersonalDetails
@age
@height
in this order.
So basically if I Parse this XDocument, I get elements separately and attributes separately which disobeys the xml hierarchy.
var attributes = xDocument.Descendants().Attributes();
var elements = xDocument.Descendants().Elements();
I am looping this separately hence i am getting attributes first and then elements
Is there any way to list using the above order ?