标签:
//XML转DataSet public static void XmlToDataTableByFile(){ XmlDocument doc = new XmlDocument(); doc.Load(@"E:\\xmlsample.xml"); DataSet ds = new DataSet(); StringReader tr = new StringReader(doc.InnerXml); //DataTable也可以ReadXml() ds.ReadXml(tr); } //DataSet转XML public static void DataTableToXml(){ //获取DataSet数据 DataSet ds = XmlToDataTableByFile(); StringWriter sw = new StringWriter(); ds.Tables[0].WriteXml(sw); //XML字符串 string XmlStr =sw.ToString(); }
标签:
原文地址:http://www.cnblogs.com/TheFutureDiary/p/4332733.html