将xml读入数据集并导入listview [英] read xml into dataset and into listview
本文介绍了将xml读入数据集并导入listview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I have xml like
<searchRQ name="edrdrd" idv="3">
<searchRQStr id="1" value="134erdfr">
<Name>MAULIK1</Name>
<LName>SHAH1</LName>
<RoolValue>ASWED11</RoolValue>
</searchRQStr>
<searchRQStr id="2" value="2134erdfr">
<Name>MAULIK2</Name>
<LName>SHAH2</LName>
<RoolValue>ASWED21</RoolValue>
</searchRQStr>
<searchRQStr id="3" value="3134erdfr">
<Name>MAULIK3</Name>
<LName>SHAH3</LName>
<RoolValue>ASWED31</RoolValue>
</searchRQStr>
<searchRQStr id="4" value="4134erdfr">
<Name>MAULIK4</Name>
<LName>SHAH4</LName>
<RoolValue>ASWED41</RoolValue>
</searchRQStr>
</searchRQ>
等... ...............
我想在数据集中读取所有数据并直接将它们显示在listview中而不使用itemtemplate< / pre>
请提供正确的示例代码
etc.................
I want to read all in dataset and display them directly into listview without itemtemplate</pre>
Pls give proper example code
推荐答案
一旦将XML读入数据集,您就会有两个表(对于你的XML)
1.表:searchRQ有2列
2.表:searchRQstr有5列。
Once you read your XML into a Dataset, you will have two tables (for your XML)
1. Table : searchRQ with 2 columns
2. Table : searchRQstr with 5 columns.
string str = "C:\\XmlFile.xml";
DataSet ds = new DataSet();
ds.ReadXml(new System.IO.StreamReader(System.Security.SecurityElement.Escape(str), System.Text.Encoding.UTF8));
DataTable searchRQ = ds.Tables[0];
DataTable searchRQStr = ds.Tables[1];
Table: searchRQ
name idv
edrdrd 3
Table: searchRQStr
id value Name LName RoolValue
1 134erdfr MAULIK1 SHAH1 ASWED11
2 2134erdfr MAULIK2 SHAH2 ASWED21
3 3134erdfr MAULIK3 SHAH3 ASWED31
4 4134erdfr MAULIK4 SHAH4 ASWED41
您可以将xml转换为数据集,如下所示:
You can convert your xml into dataset like so:
String strXML = "Your xml";
DataSet ds = new DataSet();
ds.ReadXML(strXML);
如果您的XML来自文件,那么
If your XML is from a file then
String strXMLFileName = "Your XML File Name";
DataSet ds = new DataSet();
ds.ReadXML(strXMLFileName);
这是一篇很好的文章:
http://msdn.microsoft.com/en-us/library/ekw4dh3f.aspx [ ^ ]
Here is a good article at:
http://msdn.microsoft.com/en-us/library/ekw4dh3f.aspx[^]
这篇关于将xml读入数据集并导入listview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文