In other words, the results of the LINQ query are used in the creation
of the XML tree.
For example, the following is a portion of code that builds an XML tree manually:
XElement employee = new XElement("Employees",
new XElement("Employee",
new XAttribute("id", "1"),
new XAttribute("Dept", "0001"),
new XElement("Name", "Scott"),
new XElement("Address",
new XElement("Street", "555 Main St."),
new XElement("City", "Wellington"),
new XElement("State", "FL"),
new XElement("Zip", "33414")),
new XElement("Title", "All Things Techy"),
new XElement("HireDate", "02/05/2007"),
new XElement("Gender", "M")
)
);
Through the use of the XElement and XAttribute classes, you can simply and easily construct XML.
Notice that as each new element or attribute is added to the tree during construction, the code automatically
is formatted to look like the resulting XML.
The preceding code produces the following XML:
Scott
555 Main St.
Wellington
FL
33414
All Things Techy
02/05/2007
M
Functional construction, however, enables you to do much more than just construct XML manually as
shown in the previous example.
Pages:
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268