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

Scott Klein

"Professional LINQ"


Working with Existing XML
Loading XML into a LINQ to XML tree is straightforward. You can load XML from a number of sources,
such as a string, XmlReader, TextReader, or file.
The following example illustrates how to load from a file:
XElement employees = null;
employees = XElement.Load(@"C:\Wrox\Employees.xml");
In this example, a variable called employees is declared as an XElement object (an instance of the
XElement class). The Load method of the XElement class is then used to load the raw XML from the
Employees.xml file into an XML tree and store the XML contents in the employees variable.
XML can also be loaded from a string, using the Parse method:
XElement employees = XElement.Parse(@"

107
Part II: LINQ to XML

Steve Kent
Mr. SciFi
Gaming
04/17/92
M
M


Scott Klein
Geek
All things technical
02/05/94
M
M


Joe Walling
Head Geek
All things bleeding edge
06/15/93
M
M

");
Parse has an optional Boolean overload that enables you to preserve whitespace.


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