我有一个像这样的xml文件:
<NewDataSet>
<Communications>
<ModelNumber>0x01</ModelNumber>
<ParamName>BaudRate</ParamName>
<ParamValues>
<ParamValue>9600</ParamValue>
<ParamValue>19200</ParamValue>
<ParamValue>115200</ParamValue>
</ParamValues>
<DefaultValue>502</DefaultValue>
<MaxValue></MaxValue>
<MinValue></MinValue>
</Communications>
</NewDataSet>
我试过这个从xml读取数据到数据集:
public ObservableCollection<Communication> GetCommunications()
{
DataSet ds = StoreDbDataSet.ReadDataSet();
ObservableCollection<Communication> communications = new ObservableCollection<Communication>();
foreach (DataRow communicationRow in ds.Tables["Communications"].Rows)
{
communications.Add(new Communication((UInt16)communicationRow["ModelNumber"], communicationRow["ParamName"].ToString(),
communicationRow["ParamValue"].ToString(), communicationRow["DefaultValue"].ToString(), communicationRow["MaxValue"].ToString(),
communicationRow["MinValue"].ToString()));
}
return communications;
}
但是这不能读取ParamValue
到数据集,我该怎么做才能解决这个问题?提前谢谢!