开发者

load xml into dataset with column filtering

i would like to load xml into dataset with only 2 columns (name, price)

<?xml version="1.0" encoding="utf-8" ?>
<file>
<record>
    <name>A</name>
    <address>B</address>
    <date>12-12-2010</date>
    <price>100</price>
</record>
<record>
    <name>B</name>
    <address>C</address>
    <date>01-01-1999</date>
    <price>23</price>开发者_运维百科
</record>
</file>

here is my c# code:

string myXMLfile = "C:\\asdf.xml";
DataSet ds = new DataSet();

ds.ReadXml(myXMLfile);

dataGrid1.DataSource = ds;
dataGrid1.DataMember = "record";

that displays all of the records. what can i do to filter the data?

filter dataset/dataview/datatable

or read specific xml elements and load them into dataset ?

or filtering datagrdview?

many thanks


  1. Set your dataGridView1.AutoGenerateColumns to false.
  2. Display only required columns.


How about using LINQ to XML to read from the XML XElement.Load(@"C:\asdf.xml"); Then using LINQ to filter the results and call a ToList... Why do you need to use a dataset?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜