Load(@"C:\Wrox\Employees.xml";
XmlReader rdr = employees.CreateReader();
rdr.MoveToContent();
The XmlReader can be used to quickly read nodes and its descendants.
Theremay be times when there are other components used by your existing application that are expecting
an XmlReader as input or as the source of data. The preceding example shows one way to use LINQ to
XML to provide XmlReader functionality.
XAttribute Class
The XAttribute class deals with attributes, plain and simple. Attributes are name/value pairs
associated with elements, but working with attributes is really no different from working with elements.
Attributes are similar to elements in many ways, such as their constructors and the methods in which
values and collections are returned. Writing a LINQ query expression to return a collection of attributes
is structurally and syntactically the same as writing a LINQ query expression for returning a collection
of elements.
102
Chapter 5: Understanding LINQ to XML
Elements and attributes also have their differences. For example, attributes are not nodes in an XML tree,
so they do not derive from the XNode class.
Pages:
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193