LINQ Queries with Xml Literals

Xml literals provide an alternative syntax for LINQ to Xml queries in Visual Basic code. Let’s retake the first Xml document used in the “System.Xml.Linq Namespace” section, which looks like the following but with a slight modification:

image

There is a Person element that we want to be excluded. The goal is querying all Contact elements whose age is greater than 40. Instead of recurring to the classical syntax, you can write the following code:

image

The preceding code uses new symbols for querying documents known as Xml Axis ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.