Skip to content

Instantly share code, notes, and snippets.

@andrewconnell
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewconnell/19a2bc76c8685226410a to your computer and use it in GitHub Desktop.
Save andrewconnell/19a2bc76c8685226410a to your computer and use it in GitHub Desktop.
XML vs. JSON Serialization in Server Side Code - Snippet 2
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