我有XML格式的时间表:
<timetable>
<lesson>
<nameOfLesson>Chemistry</nameOfLesson>
<day>16.02.2015</day>
<weekday>Monday</weekday>
<time>11:05-12:35</time>
<audience>514</audience>
</lesson>
<lesson>
<nameOfLesson>Mathematics</nameOfLesson>
<day>16.02.2015</day>
<weekday>Monday</weekday>
<time>13:00-14:30</time>
<audience>514</audience>
</lesson>
<timetable>
我将数据添加到List<Lesson>
。然后List中的所有数据都应该添加到TableView中的单元格中,但是我不知道从List中获取数据有多好,因为IndexPath.Row总是从过渡到新部分的零开始。
这是课程类:
public class Lesson
{
public string name, day, dayOfWeek, time, audience;
public Lesson(string _name, string _day, string _dayOfWeek, string _time, string _audience)
{
this.name = _name;
this.day = _day;
this.dayOfWeek = _dayOfWeek;
this.time = _time;
this.audience = _audience;
}
}
填充xml的第二个选项:
<timetable>
<day>
<lesson>
<nameOfLesson></nameOfLesson>
<date>16.02.2015</date>
<weekday>Monday</weekday>
<time>11:05-12:35</time>
<audience>514</audience>
</lesson>
<lesson>
<nameOfLesson></nameOfLesson>
<date>16.02.2015</date>
<weekday>Monday</weekday>
<time>13:00-14:30</time>
<audience>514</audience>
</lesson>
<lesson>
<nameOfLesson></nameOfLesson>
<date>16.02.2015</date>
<weekday>Monday</weekday>
<time>14:40-16:10</time>
<audience>514</audience>
</lesson>
</day>
<day>
<lesson>
<nameOfLesson></nameOfLesson>
<date>17.02.2015</date>
<weekday>Tuesday</weekday>
<time>13:00-14:30</time>
<audience>602</audience>
</lesson>
<lesson>
<nameOfLesson></nameOfLesson>
<date>17.02.2015</date>
<weekday>Tuesday</weekday>
<time>14:40-16:10</time>
<audience>602</audience>
</lesson>
</day>
</timetable>