【发布时间】:2015-11-17 14:34:23
【问题描述】:
<MainData id="1" >
<Info>
<Date>2015-06-08 15:00:00</Date>
</Info>
<Data DataRef="uu91"/>
<Data DataRef="uu92">
</Data>
</MainData>
我有一个 xml 文件,我想获取两个数据元素并将它们存储到两个不同的变量中,这样当我执行相同的值时就会出现。当我收到这两个值时,我想获取 ID、日期...
var data = from item in retreiveOptaHomeFixturesXml.Descendants("MainData")
select new
{
ID = item.Attribute("id").Value,
Date = item.Element("Info").Element("Date").Value,
DataRef1 = item.Element("Data").Attribute("DataRef").Value,
Dataref2 = item.Element("Data").Attribute("DataRef").Value,
};
【问题讨论】:
标签: c# linq linq-to-xml