XML : Xml Deserialize return null

I have the following class which contains the objects of class i want Deserialize the xml. i am using following technique its showing null. Actually i want to Deserialize the xml define in the last portion of question. for this purpose i use the following technique may be i am going in wrong way please correct me

  [Serializable]  public class Param   {      public Professor Professor { get; set; }      public Course Course { get; set; }  }  public class Professor  {      public int id;      public String name;        public Professor() { }  }  public class Course  {      public int id;      public String name;      public Course() { }  }    

Here folowing is the C# Code for Deserialization the xml reading from file schedule.xml sample of xml is define below

   string path = "//schedule.xml";      XmlRootAttribute xRoot = new XmlRootAttribute();      xRoot.ElementName = "param";      xRoot.IsNullable = true;      XmlSerializer serializer = new XmlSerializer(typeof(Param),xRoot);      using (StreamReader reader = new StreamReader(path))      {      param = (Param)serializer.Deserialize(reader);      }    

Here this is sample of xml defined in schedule.xml file

   <param>        <professor id='1' name='Novak J.'></professor>        <Professor id='2' name='Stanek A.'>  </Professor>        <course id='1' name='Mathematics' biolab='false'> </course>        <course id='2' name='Biology' biolab='true'>  </course>   </param>    

No comments:

Post a Comment