Krishna Ramisetty

Krishna Ramisetty

  • NA
  • 18
  • 3.3k

How to Desiralize xml object in C#

Jul 8 2021 4:54 AM

Hello Everyone,

I need to deserialize below xml object into the respective models below. how to do this. please suggest me

<RESPONSE>
<SchoolList>
<School>
<SchoolID>102</SchoolID>
<SchoolName>ABC</SchoolName>
<StudentList>
<Student>
<StudentName>JOHN</StudentName>
<ClassName>IX</ClassName>
<Age>13</Age>
</Student>
<Student>
<StudentName>Taylor</StudentName>
<ClassName>IIX</ClassName>
<Age>11</Age>
</Student>
</StudentList>
</School>
<School>
<SchoolID>103</SchoolID>
<SchoolName>BCD</SchoolName>
<StudentList>
<Student>
<StudentName>CHRIS</StudentName>
<ClassName>IV</ClassName>
<Age>9</Age>
</Student>
</StudentList>
</School>
</SchoolList>
</RESPONSE>
public class School
{
public List<Student> StudentList;
public int SchoolID { get; set; }
public string SchoolName { get; set; }
}
public class Student
{
public string StudentName { get; set; }
public string ClassName { get; set; }
public int ? Age { get; set; }
}

Thanks,

Krish


Answers (3)