From the course: .NET Essentials: LINQ for XML
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Use Query syntax to work with elements - .NET Tutorial
From the course: .NET Essentials: LINQ for XML
Use Query syntax to work with elements
- This is the chapter, where we look at how to use the LINQ Query Operators, and query expressions to query the XML data. Most of the techniques we've seen up to this point are XML specific. We've seen how to get the elements and attributes from the XML tree. We've looked at how to read values from the tree. Write the content to the tree and saved the file. We need these tools to work with XML, but they are not what we need to query the data. Now, what we need to remember is our LINQ skills. When you're working with LINQ to objects we query items that are in an IEnumerable<T>. And in the XML world, we can get an IEnumerable<T> like this. Remember that when I call the elements method I'm getting back an IEnumerable<X> element. So this is my entry into the query syntax. Once I have this, then I can use to query operators. I can use query expressions and all the world of LINQ opens up to what I can do with this data. Right…
Contents
-
-
-
-
-
(Locked)
Use Query syntax to work with elements2m 46s
-
(Locked)
Attribute query1m 27s
-
(Locked)
Select data into a new anonymous type1m 47s
-
(Locked)
Where clause on attribute value1m 53s
-
(Locked)
Where clause with compare2m 11s
-
(Locked)
Aggregate queries2m 1s
-
(Locked)
Choose output order with OrderBy42s
-
(Locked)
Query for empty elements and blank values3m 21s
-
(Locked)
Group by3m 26s
-
(Locked)
Challenge: Create custom string output1m 46s
-
(Locked)
Solution: Create custom string output1m 14s
-
(Locked)
Challenge: Filter results to show elements with no content47s
-
(Locked)
Solution: Filter results to show elements with no content55s
-
(Locked)
Challenge: Filter results to show invalid values1m 39s
-
(Locked)
Solution: Filter results to show invalid values1m 53s
-
(Locked)
-
-