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.
Query for empty elements and blank values - .NET Tutorial
From the course: .NET Essentials: LINQ for XML
Query for empty elements and blank values
- [Instructor] Depending on how you get your XML data you may need to do some validation on what's there. And if you have an XML schema, you can validate that the structure of the XML file is correct but there could be problems with the data that are in the elements. This is a big topic I want to look at some of the features that are part of linked XML that we can use to find out whether we have zero length content or whether I have empty elements. Now I'm in a special file here it's called BigStar Collectibles, MissingXML. And in this Rex card, I have a publish date which as you can see has a beginning and ending tag but it has no content. If I were to read the value out of this element I get a zero links, same with image or I don't know was another special kind of syntax you can use an XML when you don't have any content. And it's just this open tag, no close tag. So this is considered to be an empty element. We're…
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
-
-
-