SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 216 | Next

Scott Klein

"Professional LINQ"


Easley
SC

All Things Bleeding Edge
07/22/2004
M


One of the things that makes creating XML with LINQ to XML quite easy is the capability to structure the
XML directly in the programming language, formatting the source code just as it would be structured in
the XML document. Additionally, the many properties and methods of the XElement class make it easy
to efficiently structure and create XML documents dynamically.
The XElement class contains a handful of overloads that let developers create XML trees quickly within
a single statement. These constructor overloads allow you to create a new instance of the XElement class
with which to structure an XML document.
In its simplest form, the XElement class can be used to create a new element with a specific name, as
shown here in the basic syntax:
XElement(XName name)
For example, the following uses the basic syntax to create a single root element:
XElement employee = new XElement("Root");
This code produces the following XML:

126
Chapter 6: Programming with LINQ to XML
Building on that, you use the XElement constructor to create a new instance of the XElement class
(creating a new element) from another XElement object.


Pages:
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6