Opening a local XML file
In this recipe let's try to open an XML file saved in the local application folder. We will make use of the XDocument parse method for opening the XML file. LINQ to XML is the best and the easiest way to navigate the XML for Silverlight applications. LINQ to XML replaced the XSLT transformation in C#.
Getting ready
For this recipe let's create a new project named Recipe1_LinqToXml
under the solution folder named Ch3_Recipes
. We will use this solution for all our samples in this chapter. Change the Application Name in the MainPage.xaml
to LINQToXML
. Press F5 and run to make sure you have no errors.
How to do it...
In the following steps we will create an XML file with sample data for our testing purposes and then we will load the results of the LINQ to SQL query into a list box control to be displayed on the screen.
Open the
MainPage.xaml.cs
file and add the assembly reference for accessing isolated storage, which isSystem.IO.IsolatedStorage
. As we are going to use XML...