我的XML(我不能改变):反序列化XML字符串复杂类型
<result>
<type>MAZDA</type>
<make>RX-8</type>
<country>JAPAN</country>
</result>
我的模型:
[Serializable, XmlRoot("result")]
public class VehicleDetails
{
public string Type { get; set; }
public string Make { get; set; }
public string Country { get; set; }
}
反序列化这个XML按预期工作,但我想改变在Country
属性的复杂类型,像这样:
public Country Country { get; set; }
,并把国名,“日本”,在Country.Name
财产,任何想法?
感谢达林,工程巨大。我可以将两个XML节点合并为一个复杂类型吗?例如' error errormessage>',把这两个属性放到一个'public Error Error {get;组; }属性,'Error'类型有两个属性,'code'和'message'? –
eth0