From the course: .NET Essentials: LINQ for XML
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Solution: Filter results to show elements with no content - .NET Tutorial
From the course: .NET Essentials: LINQ for XML
Solution: Filter results to show elements with no content
(upbeat music) - [Instructor] I hope you had fun working on the challenge. Here's my results. Remember, your solution may be different from mine. The way I solved this, is I got all the color elements. And then I wrote a where clause, and I used the string that is NullOrEmpty, and I passed in the value. That's one way of checking for that. When I run this query, I get back two items. Both of them have, here you can see there's no value in Hue. You'll notice that this one is also missing Saturation, whereas the second one has a Saturation value. So now I'm going to add the second part of the where clause. So I did the double ampersands, and then I used a different syntax this time. I said, where the Element("Saturation").Value is equal to an empty string. Now I should get back a single element.
Contents
-
-
-
-
-
Use Query syntax to work with elements2m 46s
-
Attribute query1m 27s
-
Select data into a new anonymous type1m 47s
-
Where clause on attribute value1m 53s
-
Where clause with compare2m 11s
-
Aggregate queries2m 1s
-
Choose output order with OrderBy42s
-
Query for empty elements and blank values3m 21s
-
Group by3m 26s
-
Challenge: Create custom string output1m 46s
-
Solution: Create custom string output1m 14s
-
Challenge: Filter results to show elements with no content47s
-
Solution: Filter results to show elements with no content55s
-
Challenge: Filter results to show invalid values1m 39s
-
Solution: Filter results to show invalid values1m 53s
-
-
-