First, be careful how you use
Option Strict in this scenario. Option Strict will cause the compiler to check each type to ensure
that it has widened to the required type. This applies to everything except the root element of an XML
document. If you leave Option Strict off, expressions of type Object can be embedded, in which case
their type is verified at runtime.
183
Part II: LINQ to XML
Second, you will probably run into situations where content is optional. In those cases,
embedded expressions that contain Nothing are ignored. Thus, there is no need to check that
the values of elements or attributes are not Nothing as you use XML literals. In other words, required
values such as element and attribute names cannot be Nothing, but empty embedded expressions are
ignored. Sweet.
Embedding Queries
The fact that you can embed expressions within your XML literal should tell you that you can also
embed queries within your XML literal. When queries are embedded within the XML literal, all elements
returned by the query are added to the XML.
Pages:
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312