Search and Set Node Values
I have a XML Document (LessonData.xml) with lesson data in it, with the following format:
<Lessons>
<Lesson ID= *GUID Number*>
<FullName>John Smith&开发者_C百科lt;/FullName>
<Date>04/01/2010</Date>
</Lesson>
In C#, I have a windows app form, with a combobox. In this combobox, I have put in selections of the week dates, ie: "04/01/2010 - 10/01/2010", "11/01/2010 - 17/01/2010", etc. And then a 'Load' button.
What I want to do is select the week range from the combobox, click 'Load', then have all the lessons in that date range display (in a textbox or something).
How can I set the <Date>
to equal being part of the week selection?
Query:
var lessons = from lDate
in xmlDocument.SelectNodes("/Lessons/Lesson/Date").Cast<XmlNode>()
where DateTime.Parse(lDate.InnerText) > selectedDay
&& DateTime.Parse(lDate.InnerText) < selectedDay.AddDays(7)
select lDate.ParentNode;
Ouput:
foreach (var lesson in lessons)
lblOutput.Text += lesson.InnerXml;
精彩评论