c# - DataSet and Xml

本文介绍如何利用XML数据构造DataSet,并展示了具体的代码实现过程。通过使用DataSet的ReadXml方法,可以轻松地从XML文件中读取数据并填充到DataSet中。此外,还提到了ReadXml方法支持同时读取数据和模式。

you can work with DataSet with a lot of controls, include the infragistics XamDataGrid and the DataGrid controls. 

 

DataSet has this ReadXml method to allow you to read data from Xml, so that you can use an xml as the datasource, below shows an example of how construct DataSet with Xml.

 

      public static string xmlString2 = @"<DataRowList>
    <DataRow>
         <TradeDate>Data</TradeDate>
         <TradeType>Type</TradeType>
    </DataRow>
    <DataRow>
    </DataRow>
</DataRowList>
";
      DataSet dataset = new DataSet();
      XmlReader xmlReader = XmlReader.Create(new StringReader(xmlString2));
      dataset.ReadXml(xmlReader);
      DataView dv = dataset.Tables[0].DefaultView;
      xamDatagrid.DataSource = dv;

 

As from the DataSet.ReadXml documentation, you may find there is a ReadSchema call, (while ReadXml support reading both the xml and the schema at once).  

 

More details on the DataSet schema is yet to come.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值