using System.Collections.Generic;
public static void Main()
string xmlString = "<School><Student><Id>2</Id><Name>dummy</Name><Section>12</Section></Student><Student><Id>3</Id><Name>dummy</Name><Section>11</Section></Student></School>";
XDocument doc = new XDocument();
if (!string.IsNullOrEmpty(xmlString)){
doc = XDocument.Parse(xmlString);
List<Student> students = new List<Student>();
if(!string.IsNullOrEmpty(xmlString) && doc.Root.Elements().Any())
students = doc.Descendants("Student").Select(d=>
id=d.Element("Id").Value,
name=d.Element("Name").Value,
section=d.Element("Section").Value
Console.WriteLine(students.Count());
foreach(var item in students){
Console.WriteLine(item.id);
Console.WriteLine(item.name);
Console.WriteLine(item.section);
public class Student{public string id;public string name; public string section;}