XML:
<shift_details>
<shift_time>10:00 to 10:30</shift_time>
<count>0</count>
<shift_time>10:30 to 11:00</shift_time>
<count>0</count>
<shift_time>11:00 to 11:30</shift_time>
<count>0</count>
<shift_time>11:30 to 12:00</shift_time>
<count>0</count>
<shift_time>12:00 to 12:30</shift_time>
<count>0</count>
</shift_details>
代码:
var slots = from c in xmlResponse.Descendants("shift_details")
select new TimeSlots
{
time = (string)c.Element("shift_time"),
count = (string)c.Element("count"),
};
上面的代码只返回一个槽项作为输出。但是我的 xml 包含太多记录。
如何读取上述xml中的所有记录?