Xml文件在Asp.Net中读入数据集 [英] Xml File Read In Dataset In Asp.Net
本文介绍了Xml文件在Asp.Net中读入数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个xml文件。我想在数据集中读取这个xml文件。但是出现了这个错误。
继承其命名空间的嵌套表'链接'不能在不同的命名空间中有多个父表。
请帮帮我
Hi,
I have a xml file. I wann read this xml file in dataset. but arise this error.
"Nested table 'link' which inherits its namespace cannot have multiple parent tables in different namespaces. "
Please help me
推荐答案
string xmlFile = "Data.xml";
DataSet dataSet = new DataSet();
dataSet.ReadXml(xmlFile, XmlReadMode.InferSchema);
//你可以阅读使用
//you can read using
foreach (DataTable table in dataSet.Tables)
{
Console.WriteLine(table);
for (int i = 0; i < table.Columns.Count; ++i)
Console.Write("\t" + table.Columns[i].ColumnName.Substring(0, Math.Min(6, table.Columns[i].ColumnName.Length)));
Console.WriteLine();
foreach (var row in table.AsEnumerable())
{
for (int i = 0; i < table.Columns.Count; ++i)
{
Console.Write("\t" + row[i]);
}
Console.WriteLine();
}
}
这篇关于Xml文件在Asp.Net中读入数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文