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

Scott Klein

"Professional LINQ"

Load(tr);
tr.Close();
xel.Save(@"C:\Wrox\Employees2.xml");
Saving XML like this is commonly known as serializing. If the XML that is loaded into the XML class is
indented, the serialized XML keeps its formatting, thus maintaining the indentation of the XML, although
any insignificant whitespace is removed.
109
Part II: LINQ to XML
Creating XML
LINQ to XML provides a powerful yet easy approach to manually creating XML elements. You have seen
this method quite a bit throughout this chapter. The section ??????LINQ to XML Programming
Fundamentals??™??™ listed several classes available to you via LINQ to XML in which you can manually create
XML documents.
Here??™s an example that creates a simple XML document consisting of elements and attributes:
XElement xdoc = new XElement("Riders",
new XElement("Rider",
new XElement("Name", "Ricky Carmichael"),
new XElement("NationalNumber", "4"),
new XElement("Mechanic", "Mike Gosselaar"),
new XElement("Nickname", "GOAT")
)
);
And here??™s the output:


Ricky Carmichael
4
Mike Gosselaar
GOAT


The great thing about LINQ to XML in the .


Pages:
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6