Dictionary<string, string> dicNodes = new Dictionary<string, string>();
       foreach (XmlNode node in nodes.ChildNodes)
       {
           if (node.NodeType==XmlNodeType.Element)
           {
             
              dicNodes.Add(node.Attributes["name"].Value,node.Attributes["value"].Value);
           }
       }
        tb_b_employee Employee = new tb_b_employee();

        Type type = Employee.GetType();
       //取得属性集合
       PropertyInfo[] pi = type.GetProperties();
       foreach (PropertyInfo item in pi)
       {
           //给属性赋值
           if (dicNodes[item.Name] != null)
           {
               item.SetValue(Employee,dicNodes[item.Name], null);
           }
       }

  

相关文章:

  • 2022-12-23
  • 2021-11-04
  • 2021-09-10
  • 2021-07-27
  • 2022-12-23
  • 2021-07-05
猜你喜欢
  • 2021-07-30
  • 2022-02-27
  • 2022-01-17
  • 2022-12-23
  • 2021-08-21
  • 2021-08-21
  • 2022-12-23
相关资源
相似解决方案