什么也不多说,直接贴代码
需要反序列的XML
<?xml version='1.0' encoding='utf-8' ?> <GetCitiesListResponse> <Result Code='000000'>成功</Result> <CitiesList> <City PinYin='ZHANJIANG' HasOutService='N'>湛江</City> <City PinYin='zhangzhou' HasOutService='N'>漳州</City> </CitiesList> </GetCitiesListResponse>
反序列化Model:
class="brush:csharp;gutter:true;"> [XmlRoot("GetCitiesListResponse")] public class GetCitiesListResponse { public Result Result { get; set; } [XmlArray("CitiesList"), XmlArrayItem("City")] public City[] CitiesList { get; set; } } public class Result { [XmlAttribute("Code")] public string Code { get; set; } [XmlText] public string Value { get; set; } } [XmlRoot("City")] public class City { [XmlAttribute("PinYin")] public string PinYin { get; set; } [XmlAttribute("HasOutService")] public string HasOutService { get; set; } [XmlText] public string Value { get; set; } }
后台代码不算本话题的核心,就不贴出来了。。。。。。。