Sorting Xml file based on an element

Hello,
I’m trying to order an xml file containing foods based on a specified element (calories).
I managed to get all the elements under food in a collection of IEnumerable xelements.
I’dont know if or how we can use the OrderBy and OrderByDescneding function on a collection of xelement or if there is another method.
Xml file contains the following
<breakfast_menu>

Belgian Waffles
$5.95

Two of our famous Belgian Waffles with plenty of real maple syrup

650


Strawberry Belgian Waffles
$7.95

Light Belgian waffles covered with strawberries and whipped cream

450


Berry-Berry Belgian Waffles
$8.95

Light Belgian waffles covered with an assortment of fresh berries and whipped cream

300

</breakfast_menu>

Please help me

1 Like

Hey @ahmed.alakhal-benltaifa

So you don’t have a tag for calories ?

Thanks
#nK

Hey @Nithinkrishna yes it does. This is a picture of the xml file .

1 Like

Perfect, You can do the DataTable.ReadXML and from the data table I hope you know how to sort and get it !

1 Like

for this file:

we can sort the foods like

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.