具有不同架构的DataSet.ReadXml [英] DataSet.ReadXml with Different Schema
本文介绍了具有不同架构的DataSet.ReadXml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在使用数据集读取xml文件. xml文件是由不同的技术(例如VFP,PHP,.Net)生成的,并且具有不同的架构.
我尝试了以下方式来读取xml,但不足以读取所有类型的xml文件:
Hi All,
I am using dataset to read xml file. The xml file is being generated by different technologies (like VFP, PHP, .Net) and has different schema.
I have tried the following ways to read xml but not good enough to read all kind of xml file :
DataSet dSet = new DataSet();
dSet.ReadXml("FilePath", XmlReadMode.ReadSchema|XmlReadMode.IgnoreSchema |XmlReadMode.InferSchema);
// OR
dSet.ReadXml("FilePath", XmlReadMode.InferSchema);
// OR
dSet.ReadXml("FilePath", XmlReadMode.IgnoreSchema);
//OR
dSet.ReadXml("FilePath", XmlReadMode.Auto);
并获取空数据集或出现以下错误:
And getting either empty dataset or following Error:
//Error
XMLSchemaInferenceException
The supplied xml instance is a schema or contains an inline schema. This class cannot infer a schema for a schema.
哪种方法是读取所有类型的xml文件并填充数据集的最佳,最快的方法?
问候!
Aman
Which is best and fast way to read All kind of xml file and fill dataset?
Regards!
Aman
推荐答案
如果XML具有有效的架构,或者可以推断出该XML,则只需调用DataSet.ReadXml(source)即可.如果没有,您可能必须先使用XSLT或自定义代码翻译某些内容.
If the XML has a valid schema, or it can be inferred, just calling DataSet.ReadXml(source) should work. If not, you might have to translate something with XSLT or custom code first.
这篇关于具有不同架构的DataSet.ReadXml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文