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); } }