这个 xml 数据对我来说有点棘手,它的结构如下:
<site time="local">
<key>000-000-000</key>
<valid-time period-name="Monday">2012-09-03T06:00:00-04:00</valid-time>
<valid-time period-name="Tuesday">2012-09-04T06:00:00-04:00</valid-time>
<valid-time period-name="Wednesday">2012-09-05T06:00:00-04:00</valid-time>
<valid-time period-name="Thursday">2012-09-06T06:00:00-04:00</valid-time>
</site>
<site time="local">
<key>123-456-789</key>
<valid-time period-name="Monday">2012-09-03T06:00:00-04:00</valid-time>
<valid-time period-name="Tuesday">2012-09-04T06:00:00-04:00</valid-time>
<valid-time period-name="Wednesday">2012-09-05T06:00:00-04:00</valid-time>
<valid-time period-name="Thursday">2012-09-06T06:00:00-04:00</valid-time>
</site>
...more <site time="">...
我这样做是为了获取数据:
xmlCurrent = from d in Xmldata.Descendants("site")
.Where(s => s.Element("key").Value.Equals("123-456-789"))
.Select(x => new { content = x.Value})
.ToList();
但是所有内容都作为单个字符串进入列表的一个索引,如何将每个值放入不同的索引?