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

Solution: Filter results to show elements with no content - .NET Tutorial

From the course: .NET Essentials: LINQ for XML

Start my 1-month free trial

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