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.

Challenge: Filter results to show invalid values

Challenge: Filter results to show invalid values - .NET Tutorial

From the course: .NET Essentials: LINQ for XML

Start my 1-month free trial

Challenge: Filter results to show invalid values

(upbeat music) - [Instructor] Are you ready for another code challenge? This time we're looking for information inside this WebColorsB.xml file and we're looking for two things. You can write a query expression that finds ColorName values that contain a full stop or a period. This is not a valid name in our company. So, we want to verify that there's no periods in any of the ColorNames. The second thing we want to verify is that our HexValues are correct. Now, HexValues or hexadecimal values are zero through nine and then A, B, C, D, E and F. So, if there's a letter like T anywhere in the HexValue, then that's incorrect. So, you're going to write a query that tries to evaluate whether there's invalid characters. Then you're going to combine those both into a single query expression. Now, the way I solved this is I wrote a method called IsValidHex and I'm using that in my query. And if you want to follow in line and…

Contents