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