本文介绍了无法读取DataSet的xml?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 首先我创建DataSet对象 DataSet ds = new DataSet(); 然后我加载xmlscheme。 ds.ReadXmlSchema( C:/ Users / Levan / Dcuments / Visual Studio 2012 / Projects / Crashop / CarLibrary / CarDataSet.xsd); 它加载很好。我使用数据集可视化器进行调试.Xmlscheme具有以下结构表 汽车(carname(字符串),carnumber(字符串),cardiscription(字符串),CarID(int))。比我尝试loadxml ds.ReadXml( C:/ Users / Levan / Documents / Visual Studio 2012 / Projects / Crashop / CarLibrary / CarPark.xml); xml文件具有以下结构 <? xml version = 1.0 standalone = 是 ? > < NewDataSet > < 汽车 > < carname > BMW < / carname > < carnumber > AA2935IO < / carnumber > < cardiscription > 汽车< / cardiscription > < ; CarID > 1 < / CarID > < ; / Cars > < 汽车 > < carname > Mersedes < / carname > < carnumber > AA2235IO < / carnumber > < cardiscription > 好车< / cardiscription > & CarID > 2 < / CarID > < / Cars > < / NewDataSet > 结果没有错误,但空表。 ds.Tables [ 汽车]。行。添加( BMW, AA2935IO, 好车, 1 ); 工作正常。但我想知道如何从XML文件中读取。在我使用一切都很好的例子中,我找不到合适的解决方案。解决方案 First I create DataSet object DataSet ds = new DataSet();Then I load xmlscheme.ds.ReadXmlSchema("C:/Users/Levan/Dcuments/Visual Studio 2012/Projects/Crashop/CarLibrary/CarDataSet.xsd"); It load's fine.I use Dataset visualizer for debugging.Xmlscheme has following structure Table Cars(carname(string),carnumber(string),cardiscription(string),CarID(int)).Than I try loadxml ds.ReadXml("C:/Users/Levan/Documents/Visual Studio 2012/Projects/Crashop/CarLibrary/CarPark.xml"); xml file has following structure <?xml version="1.0" standalone="yes"?><NewDataSet> <Cars> <carname>BMW</carname> <carnumber>AA2935IO</carnumber> <cardiscription>Nice car</cardiscription> <CarID>1</CarID> </Cars> <Cars> <carname>Mersedes</carname> <carnumber>AA2235IO</carnumber> <cardiscription>Nice car</cardiscription> <CarID>2</CarID> </Cars></NewDataSet>In result no errors,but empty table.ds.Tables["Cars"].Rows.Add("BMW","AA2935IO","Nice Car",1); Works fine.But i want to figure out how to read from XML file.In example which i use everything good and i didn't find appropriate solution for me. 解决方案 这篇关于无法读取DataSet的xml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-22 03:54