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 260 | Next

Scott Klein

"Professional LINQ"


With functional construction you can create a new XML from the elements and attributes of the source
XML tree, transforming the shape of the XML as the new XML tree is created and as the elements and
attributes are added to the new tree, all within a single statement. The key to functional construction is
to pass the results of LINQ queries to XElement or XDocument constructors.
One of the benefits of functional construction is that it allows you to visualize more easily how the finished
XML tree will look as you build it.
For example, the following code loads the same XML file from the previous example and uses functional
construction to build a new XML tree with a new root node and all the employee information from the
source XML tree. It also creates two new elements from the attributes of the Employee element.
XElement emp = XElement.Load(@"C:\Wrox\LINQ\Chapter 5\Employees2.xml");
XElement newXML = new XElement("Root",
emp.Element("Employee"),
from att in emp.Element("Employee").Attributes()
select new XElement(att.Name, (string)att));
textbox1.


Pages:
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6