<?xml version="1.0" encoding="utf-8" ?>
<productxml>
<product>
<brand>
<a>123</a>
<a>456</a>
</brand>
<price>
<a>111</a>
</price>
</product>
</productxml>
一个这样的xml文件,把它读到dataset中
static void Main(string[] args)
{
DataSet ds = new DataSet();
FileStream stream = new FileStream(@"D:\My Projects\WindowsFormsApplication10\ConsoleApplication1\XMLFile2.xml", FileMode.Open);
ds.ReadXml(stream);
DataRelationCollection col = ds.Tables["price"].ChildRelations;
foreach (DataRelation r in col)
{
Console.WriteLine(r.RelationName);
}
Console.Read();
}
ds.Tables["brand"].ChildRelations可以得到,但ds.Tables["price"].ChildRelations却得不到,如果给price再增加一个a tag,则可以读到,请教为什么