不是说dataSet是存储表结构的吗,xml的树形结点结构读取到dataSet中之后会是怎么样的呢
解决方案 »
- 请问下一下为什么下面的语句不报错
- C#中新建线程时,线程能否启动一个带参数的函数
- 我写了一个类(class1.cs中) ,如何在窗体中使用这个类?
- axWindowsMediaPlayer如何重新加载播放列表?
- treeview的问题(高手们帮忙了)
- 有关 Dev Express 的 BarManager 控件, 有经验的请进来做答
- 请老师..散分中..(有空的都进来看看)
- 请问在数据库中更新时怎样更新为空null
- 怎么设定.net的时间显示格式?
- C# dllimport 出错 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
- 关于在文本框的Enter事件去设置焦点后,代码执行过程很不解。
- C#中如何调用C++的函数?高手请进!~
/// 获取XML数据库中的数据的方法
/// </summary>
/// <param name="strFilePath">传入文件路径</param>
/// <returns>返回一个数据集</returns>
public static DataSet GetAllDataFromXML(string strFilePath)
{
DataSet ds = new DataSet();
FileInfo fileInfo = new FileInfo(strFilePath);
if (fileInfo.Exists)
{
try
{
ds.ReadXml(strFilePath);
}
catch { }
}
else
{
ds = null;
}
if (ds != null)
{
if (ds.Tables[0].Rows.Count < 1)
ds = null;
}
return ds;
}自己试一试就知道了
- <header>
<code>ptcgdd001</code>
<date>2002-08-02</date>
<vendorcode>002</vendorcode>
<deptcode>0801</deptcode>
<personcode>080102</personcode>
<purchase_type_code>1</purchase_type_code>
<operation_type_code>普通采购</operation_type_code>
<address />
<recsend_type>02</recsend_type>
<currency_name>人民币</currency_name>
</header>
- <body>
- <entry>
<inventorycode>0001</inventorycode>
<checkflag>0</checkflag>
<unitcode>11001</unitcode>
<quantity>500</quantity>
<num>500</num>
<quotedprice>0</quotedprice>
<price>10</price>
<taxprice>11.7</taxprice>
<money>5000</money>
<tax>850</tax>
<sum>5850</sum>
<discount>0</discount>
<natprice>10</natprice>
<natmoney>5000</natmoney>
<assistantunit>11001</assistantunit>
<nattax>850</nattax>
<natsum>5850</natsum>
<natdiscount>0</natdiscount>
<taxrate>17</taxrate>
</entry>
- <entry>
<inventorycode>0004</inventorycode>
<checkflag>0</checkflag>
<unitcode>11001</unitcode>
<quantity>1000</quantity>
<num>1000</num>
<quotedprice>0</quotedprice>
<price>11.9658</price>
<taxprice>14</taxprice>
<money>11965.81</money>
<tax>2034.19</tax>
<sum>14000</sum>
<discount>0</discount>
<natprice>11.9658</natprice>
<natmoney>11965.81</natmoney>
<assistantunit>11001</assistantunit>
<nattax>2034.19</nattax>
<natsum>14000</natsum>
<natdiscount>0</natdiscount>
<taxrate>17</taxrate>
</entry>
</body>
</purchaseorder>