Sorting Xml file based on an element

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

Belgian Waffles

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


Strawberry Belgian Waffles

Light Belgian waffles covered with strawberries and whipped cream


Berry-Berry Belgian Waffles

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



Please help me

1 Like

Hey @ahmed.alakhal-benltaifa

So you don’t have a tag for calories ?


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.