19.10 LINQ to XML: XML Literals and Embedded Expressions

Visual Basic’s XML literals allow you to write XML documents and elements directly in your code. XML literals are compiled into an XElement object, allowing you to use the techniques we’ve already shown to further manipulate the data. Without XML literals, you would have to manually call the XElement constructors—multiple nested constructor calls are not nearly as clear as plain XML.

In addition to XML literals, Visual Basic provides embedded expressions, which allow you to write Visual Basic code inside XML literals. Using embedded expressions, you can insert values obtained in your code when you create the XElement from the XML literal instead of having to insert them later after creating ...

Get Visual Basic® 2012 How to Program, Sixth Edition 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.