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

Scott Klein

"Professional LINQ"

Load(@"C:\Wrox\LINQ\Chapter 5\Employees2.xml");
XmlElement xel = xdoc.CreateElement("Location");
xel.InnerText = "SE";
xdoc.DocumentElement.AppendChild(xel);
xdoc.Save(@"C:\Wrox\LINQ\Chapter 5\Employees3.xml");
The following example uses a similar approach using functional construction:
XElement xel = XElement.Load(@"C:\Wrox\LINQ\Chapter 8\Employees2.xml");
XElement newXML = new XElement("Employee",
xel.Element("Employee").Element("Name"),
from atts in xel.Element("Employee").Attributes()
select new XElement(atts.Name, (string)atts)
);
}
newXML.Save(@"c:\wrox\LINQ\chapter5\employee4.xml");
This code loads an XML tree from a file, selecting a particular attribute of the Employee node and creating
a new element from that attribute, and then removes the selected attribute. The code produces the
following XML tree:

Scott
1
0001

Functional construction provides a much more efficient and robust way of modifying XML trees and
documents because it treats the modification of data as a problem of transformation, not as a modification
or manipulation of the data source.


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