The following code shows how to load an element and display
its contents:
Dim emp As XElement = XElement.Load("c:\Wrox\Linq\Chapter9\employees.xml")
Me.Textbox1.Text = emp.ToString
As you know, once you have XML loaded into an XElement, as in the preceding example, you
are free to manipulate and query it. Your homework for this chapter is to use a query expression
within an XML literal to return XML containing the ID of the employee along with his
name and title.
Manipulating XML Using the Parse Method
There is a method on the XElement class called Parse, which loads a string containing XML into an
XElement. There is an overload on this method that enables you to specify options when parsing the
XML being loaded.
In the following example, a string variable is defined and loaded with an XML fragment. The
string is then passed to the Parse method of the XElement class. The additional parameter for
189
Part II: LINQ to XML
the load options specifies a value of None, meaning that no load options are being specified. Load options
are explained shortly.
Pages:
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321