Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Applies to Silverlight 3, 4 and 5
We have successfully connected to a REST service from a Silverlight application in the previous recipe. The response from the service is XML. Most of the time, showing pure XML to the end user is not the goal of an application, so we'll want to parse the XML. Silverlight contains several options to work with XML, which include XmlReader/XmlWriter, XmlSerializer, and LINQ To XML (also known as XLinq). The latter is a preferred way to parse XML.
In this recipe, we'll look at how we can use LINQ To XML to transform XML into real data. The raw user data (originally in XML) will be transformed in User objects.
This recipe builds on the code created in the previous recipe, so you can continue using that solution. Alternatively, you can use the starter solution for this recipe located in the Chapter10/TalkingToSimpleRESTServices_LinqToXml_Starter folder in the code bundle available on the Packt website. The finished solution for this recipe can be found in the Chapter10/TalkingToSimpleRESTServices_LinqToXml_Completed folder.