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 - .NET Tutorial
From the course: .NET Essentials: LINQ for XML
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
-
-
-
-
-
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
-
-
-