Part 3 Querying xml document using linq to xml

preview_player
Показать описание
In Parts 1 and 2 of LINQ to XML tutorial, we discussed creating XML documents using LINQ to XML.

Text version of the video

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.

Slides

LINQ to SQL Tutorial - All Text Articles & Slides

LINQ to XML Tutorial Playlist

Dot Net, SQL, Angular, JavaScript, jQuery and Bootstrap complete courses

In this video, we will discuss how to query xml document using linq to xml. We want to retrieve all the student names who has TotalMarks greater than 800. Students names should be sorted by TotalMarks in descending order.

where (int)student.Element("TotalMarks") ] 800
orderby (int)student.Element("TotalMarks") descending
select student.Element("Name").Value;

foreach (string name in names)
{
Console.WriteLine(name);
}

Alternate way of writing the above query.
where (int)student.Element("TotalMarks") ] 800
orderby (int)student.Element("TotalMarks") descending
select student.Element("Name").Value;
Рекомендации по теме
Комментарии
Автор

🙏🏼🥳 may the universe bless you! you saved my day ❤️

woopwoop
Автор

Very well explained as always! Greetings from sweden

peterl
Автор

I appreciate your tutorials...very well done.Thank you

Tall-Cool-Drink
Автор

What to do if I want to get All records as a type of List<Student> ?

Can you please explain ?

sijimathew
Автор

Hi I am trying to query XML as you have shown in video but at .Descendents I am keep getting error

Could not find an implementation of the query pattern for source type 'Select' not found. Are you missing a reference to 'System.Core.dll' or a using directive for 'System.Linq'?

tarangchaurasia
Автор

thank you a lot Mr,
But i want to ask you how do i can get the attribute value of the student .101, 102,103,104

alainsaab