只能处理简单结构XML 和 实体. using System.Text; using System.Xml; namespace A.Util { public static class MyXmlUtil { public static string ModelToXml<T>(T a ,string xmlRootName) { StringBuilder scXml = new StringBuilder(); scXml.AppendFormat("<{0}>&q…
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) …
using System; using System.Linq; using System.Xml; using System.Reflection; using System.Data; using System.Collections.Generic; namespace IOSerialize.Serialize { public static class xHelper { /// <summary> /// 实体转化为XML /// </summary> public s…
我们需要在XML与实体类,DataTable,List之间进行转换,下面是XmlUtil类,该类来自网络并稍加修改. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Data; using System.Xml; using System.Xml.Serialization; /// <summary> ///…