C# 获取xml数据,并转换为dataset
2014-01-08 09:46
309 查看
//获取xml数据,并转换为dataset public static DataSet getConfig(string strXmlPath) { string filePath = GetPhysicalPath(); DataSet ds= ConvertXMLFileToDataSet(GetXmlFullPath(filePath)); return ds; } //将xml文件转换为DataSet public static DataSet ConvertXMLFileToDataSet(string xmlFile) { StringReader stream = null; XmlTextReader reader = null; try { XmlDocument xmld = new XmlDocument(); xmld.Load(xmlFile); DataSet xmlDS = new DataSet(); stream = new StringReader(xmld.InnerXml); //从stream装载到XmlTextReader reader = new XmlTextReader(stream); xmlDS.ReadXml(reader); //xmlDS.ReadXml(xmlFile); return xmlDS; } catch (System.Exception ex) { throw ex; } finally { if (reader != null) reader.Close(); } }
相关文章推荐
- c#调用COM组件
- IE:获取完整的网页
- As3.0 xml + Loader应用代码
- c#中虚函数的相关使用方法
- 网马生成器 MS Internet Explorer XML Parsing Buffer Overflow Exploit (vista) 0day
- ext读取两种结构的xml的代码
- 浅析C# web访问mysql数据库-整理归纳总结
- C# IP地址与整数之间转换的具体方法
- asp下查询xml的实现代码
- sqlserver FOR XML PATH 语句的应用
- 使用sp_xml_preparedocument处理XML文档的方法
- C#实现的阴历阳历互相转化类实例
- C# 的关键字详细介绍
- oracle SCN跟TIMESTAMP之间转换
- c# 获得局域网主机列表实例
- C#中Convert.ToInt32()和int.Parse()的区别介绍
- C#面向对象特征的具体实现及作用详解
- 关于C# Math 处理奇进偶不进的实现代码
- c# 随机函数的使用详解
- c#之圆形无标题栏椭圆窗体的实现详解