Last active
August 29, 2015 14:11
-
-
Save andrewconnell/19a2bc76c8685226410a to your computer and use it in GitHub Desktop.
XML vs. JSON Serialization in Server Side Code - Snippet 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XNamespace a = "http://www.w3.org/2005/Atom"; | |
XNamespace d = "http://schemas.microsoft.com/ado/2007/08/dataservices"; | |
XNamespace m = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"; | |
XElement root = XElement.Parse(responseString); | |
List<Task> tasks = new List<Task>(); | |
foreach (XElement entryElement in root.Elements(a + "entry")) | |
{ | |
Task task = new Task(); | |
task.Id = entryElement.Descendants(m + "properties").Descendants(d + "Id").First().Value; | |
task.Title = entryElement.Descendants(m + "properties").Descendants(d + "Title").First().Value; | |
task.Status = entryElement.Descendants(m + "properties").Descendants(d + "Status").First().Value; | |
task.Priority = entryElement.Descendants(m + "properties").Descendants(d + "Priority").First().Value; | |
try { task.AssignedTo = entryElement.Descendants(a + "entry").Descendants(d + "Name").First().Value; } | |
catch { } | |
tasks.Add(task); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment