zoukankan      html  css  js  c++  java
  • C# 不是序列化xml 转实体Model【原家独创】

    public static T XmlConvertModel<T>(string xmlStr) where T : class, new()
            {
                T t = new T();
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(xmlStr);
                foreach (XmlNode xnls in xmlDoc.ChildNodes)
                {
                    if (xnls.Name.ToUpper() == typeof(T).Name.ToUpper())
                    {
                        foreach (XmlNode xnl in xnls.ChildNodes)
                        {
                            System.Reflection.PropertyInfo[] propertyInfo = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
                            foreach (System.Reflection.PropertyInfo pinfo in propertyInfo)
                            {
                                if (xnl.Name.ToUpper() == pinfo.Name.ToUpper())
                                {
                                    pinfo.SetValue(t, xnl.InnerText, null);
                                    break;
                                }
                            }
                        }
                    }
                }
                return t;

            }

  • 相关阅读:
    thinkphp配置加载
    thinkphp数据输出
    thinkphp 命名规范
    array_fill — 用给定的值填充数组
    array_fill_keys — 使用指定的键和值填充数组
    array_change_key_case — 将数组中的所有键名修改为全大写或小写
    HTMLCSS样式表
    MySql查询语句中的变量使用
    使用java8的方法引用替换硬编码
    如何搭建一个自己的网站(绝对详细~)
  • 原文地址:https://www.cnblogs.com/LuoEast/p/11851984.html
Copyright © 2011-2022 走看看