如何将此xml数据添加到数据集? [英] How to add this xml data to dataset?
本文介绍了如何将此xml数据添加到数据集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以前我的xml是这样的
previously my xml was like this
<?xml version="1.0" encoding="UTF-8"?>
<root>
<supplier>
<s_code>1</s_code>
<net_weight>100</net_weight>
<rate>100.00</rate>
</supplier>
<supplier>
<s_code>2</s_code>
<net_weight>500</net_weight>
<rate>150.00</rate>
</supplier>
</root>
所以我创建了一个数据集并添加了与此类似的列,并使用此代码将数据加载到数据集中并使用数据集创建了水晶报表.
so i created a dataset and added columns similar to this and used this code to load data into dataset and use dataset to create crystal report.
DataSet reportData = new DataSet();
reportData.ReadXml("http://192.168.1.10/test/data.xml");
DataSet dset = new DataSet1();
dset.Tables[0].Merge(reportData.Tables[0]);
ReportDocument report = new CrystalReport1();
report.SetDataSource(dset.Tables[0]);
reportViewer.ViewerCore.ReportSource = report;
所以现在我需要向报表添加更多信息,而xml看起来像这样
so now i need to add more information to report and xml looks like this
<?xml version="1.0" encoding="UTF-8"?>
<root>
<supplier>
<s_code>1</s_code>
<net_weight>100</net_weight>
<rate>100.00</rate>
<items>
<item_code>SKU001</items_code>
<price>100</price>
</items>
<items>
<item_code>SKU002</items_code>
<price>200</price>
</items>
</supplier>
<supplier>
<s_code>2</s_code>
<net_weight>500</net_weight>
<rate>150.00</rate>
<items>
<item_code>SKU001</items_code>
<price>100</price>
</items>
</supplier>
</root>
所以知道如何将项目插入数据集中并在报表中使用它吗?
关于
so any idea how to insert items into a dataset and use it in report?
Regards
推荐答案
使用此链接.......这可能对您有帮助....
http://www.dotnetperls.com/数据集 [^ ]
Use this link.......This may help you....
http://www.dotnetperls.com/dataset[^]
尝试这样..
Try like this..
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml("xml filename");
谢谢
--RA
Thanks
--RA
http://stackoverflow. com/questions/894451/import-xml-into-dataset-c-sharp [ http://support.microsoft.com/kb/311566 [
http://stackoverflow.com/questions/894451/import-xml-into-dataset-c-sharp[^]
http://support.microsoft.com/kb/311566[^]
这篇关于如何将此xml数据添加到数据集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文