O'Reilly logo

Silverlight 4 Data and Services Cookbook by Kevin Dockx, Gill Cleeren

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required