我的课:
public class Device
{
int ID;
string Name;
List<Function> Functions;
}
和类功能:
public class Function
{
int Number;
string Name;
}
我有这个结构的xml文件:
<Devices>
<Device Number="58" Name="Default Device" >
<Functions>
<Function Number="1" Name="Default func" />
<Function Number="2" Name="Default func2" />
<Function Number="..." Name="...." />
</Functions>
</Device>
</Devices>
这是代码,我正在尝试读取对象:
var list = from tmp in document.Element("Devices").Elements("Device")
select new Device()
{
ID = Convert.ToInt32(tmp.Attribute("Number").Value),
Name = tmp.Attribute("Name").Value,
//??????
};
DevicesList.AddRange(list);
我如何阅读“功能”???