I'm very new to XML. The following xml is received as a string from a webservice
"<settings>
<calculator display="1" />
<details display="1" />
<charge display="1" />
<features>
<feature code="HAZ" description="CARGO" />
<feature code="IDL" description="DELIVERY" />
<feature code="LFT" description="TRUCK" />
<feature code="NFY" description="CARRIER CHARGE" />
</addons>
</settings> "
And below are user-configuration which has a list as a property.
public class UserConfiguration
{
public int calculator { get; set; }
public int details { get; set; }
public int charge { get; set; }
public List<Accessorial> features { get; set; }
}
public class Accessorial
{
public string code { get; set; }
public string description { get; set; }
}
I have tried the following but the values are null;
XmlSerializer deserializer = new XmlSerializer(typeof(UserConfiguration), new XmlRootAttribute("root"));
var objectValue = deserializer.Deserialize(new StringReader(xml));
I had also put XmElement("calculator")
and so, on the properties according to some answers on stackoverflow but they also didn't work.