Parsing REST results with LINQ-To-XML
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.
Getting ready
This recipe builds on the code created in the previous recipe, so you can continue using that ...
Get Silverlight 4 Data and Services Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.