I am using silverlight ot achieve deserialisation of xml which looks like this:
String xmlString=
<attributes>
<value>1</value>
<showstatus>yes</showstatus>
<disableothers>
<disableother>
<disablevalue>1</disablevalue>
<todisable>skew</todisable>
<todisable>skew_side</todisable>
</disableother>
<disableother>
<disablevalue>0</disablevalue>
<todisable>automodel</todisable>
</disableother>
</disableothers>
</attributes>
In my attempt to achieve this i feel like i have something in the classes. The classes are as below:
[XmlRoot(ElementName = "attributes")]
public class Attributes
{
[XmlElement("disableOthers")]
public List<DisableOthers> DisableOthers { get; set; }
}
[XmlRoot(ElementName = "disableOthers")]
public class DisableOthers
{
[XmlElement("disableOthers")]
public List<DisableOther> DisableOther { get; set; }
}
[XmlRoot(ElementName = "disableOther")]
public class DisableOther
{
[XmlElement("disablingitem")]
public int DisablingItem { get; set; }
[XmlElement("todisable")]
public int ToDisable { get; set; }
[XmlElement("disablevalue")]
public int DisableValue { get; set; }
}
Could some one please correct me if my classes are correct corresponding to the given xml ? Would be a big help.
NOTE: The problem exact is when i created object of the parent class then it gives "0" value. And i have already tried it then i came here on stackoverflow.
You don't need
DisableOthers
class. Just use property withXmlArrayItem
attribute:Complete mapping looks like:
Deserialization:
Output:
/* if you want read objects from xml to c# code
*/
//if you want opposite, you have objects to save in xml