如何将子表添加到数据集表并访问它 [英] How to add a sub table to a dataset table and access it
本文介绍了如何将子表添加到数据集表并访问它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前的数据来自xml。我的应用程序通过php服务器接口收集sql数据.. php以xml格式返回数据..
Hi, im currently with data coming from xml. my application gather sql data through a php server interface.. the php return data in xml format..
xml以这种方式格式化。
the xml is formatted this way.
<Clients>
<Client>
<ClientDataA>Data a</ClientDataA>
<ClientDataB>Data b</ClientDataB>
<ClientDataC>Data c</ClientDataC>
<ClientDataD>Data d</ClientDataD>
<Products>
<Product>
<Name>name</Name>
<Id>0001</Id>
<Description>bla bla bla</Description>
</Product>
<Product>
<Name>name</Name>
<Id>0002</Id>
<Description>bla bla bla</Description>
</Product>
<Product>
<Name>name</Name>
<Id>0003</Id>
<Description>bla bla bla</Description>
</Product>
</Products>
</Client>
</Clients>
推荐答案
它确实读取了结构,找到你的表运行这段代码并检查,我已将你的xml保存在桌面上的文件中因此路径...使用你的xml路径...
It does read the structure, to locate your table run this code and check, I have saved your xml in a file on the desktop hence the path... use your path to the xml...
private void Form1_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds.ReadXml(@"C:\Users\Admin\Desktop\product.xml", XmlReadMode.Auto);
for (int i = 0; i < ds.Tables.Count; i++)
{
MessageBox.Show(ds.Tables[i].TableName + " Index : " + i.ToString());
}
}
这篇关于如何将子表添加到数据集表并访问它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文