XML转实体对象
public CheckoutOutputParms Checkout(CheckoutInputParms input) { string str = File.ReadAllText(Server.MapPath("App_Data/ShippingTypeList.xml")); CheckoutOutputParmsList shipTypeList = new CheckoutOutputParmsList(); using (StringReader sr = new StringReader(str))//读取xml配置文件 { XmlSerializer xs = new XmlSerializer(typeof(CheckoutOutputParmsList)); shipTypeList = xs.Deserialize(sr) as CheckoutOutputParmsList; } List<CheckoutOutputParms> AllshipTypeList = new List<CheckoutOutputParms>(); AllshipTypeList = shipTypeList.checkoutOutputParmsList; CheckoutOutputParms result = GetShipTypeFee(AllshipTypeList, input); return result; } public class CheckoutOutputParmsList { [XmlArray("ShippingInfo")] [XmlArrayItem("Table")] public List<CheckoutOutputParms> checkoutOutputParmsList { get; set; } } public class CheckoutOutputParms { [XmlElement("Areas")] public string Areas { get; set; } [XmlElement("SOAmount")] public int SOAmount { get; set; } [XmlElement("ShippingFee")] public decimal ShippingFee { get; set; } }
作者:Bober Song
出处:http://bober.cnblogs.com/
CARE健康网: http://www.aicareyou.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
出处:http://bober.cnblogs.com/
CARE健康网: http://www.aicareyou.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。