How can i deserialize this xml using Linq?
I want to create List
1
string xml = @"
1
Step 1
Step 1 Description
2
Step 2
Step 2 Description
3
Step 3
Step 3 Description
4
Step 4
Step 4 Description
";
XDocument doc = XDocument.Parse(xml);
var mySteps = (from s in doc.Descendants("Step")
select new
{
Id = int.Parse(s.Element("ID").Value),
Name = s.Element("Name").Value,
Description = s.Element("Description").Value
}).ToList();
Heres how you would do it using LINQ. Obviously you should be doing your own error checking.