private void ParseClasses(HtmlDocument document) { int classIndex = 0; int detailsIndex = 0; int profCount = 0; List <Course> courses = new List <Course>(); while (document.GetElementbyId("CLASS_TBL_VW_CLASS_SECTION$" + classIndex) != null) { HtmlNode classDescription = document.GetElementbyId("win1divDERIVED_SSE_DSP_CLASS_DESCR$" + classIndex); string className = classDescription.FirstChild.InnerText; string section = document.GetElementbyId("CLASS_TBL_VW_CLASS_SECTION$" + classIndex).InnerText; string type = document.GetElementbyId("PSXLATITEM_XLATSHORTNAME$95$$" + classIndex).InnerText; string credits = document.GetElementbyId("STDNT_ENRL_SSVW_UNT_TAKEN$" + classIndex).InnerText; string classStatus = document.GetElementbyId("PSXLATITEM_XLATSHORTNAME$" + classIndex).InnerText; string profName = string.Empty; try { profName = document.GetElementbyId("PERSONAL_VW_NAME$135$$" + profCount).InnerText; } catch (NullReferenceException) { } Course course = new Course(className, section, credits, classStatus, profName, type); if (!string.IsNullOrEmpty(profName)) { profCount++; } HtmlNode node = document.GetElementbyId("CLASS_TBL_VW_CLASS_SECTION$" + (classIndex + 1)); if (node != null) { while (document.GetElementbyId("CLASS_MTG_VW_MEETING_TIME_START$" + detailsIndex) != null && document.GetElementbyId("win1divCLASS_MTG_VW_MEETING_TIME_START$" + detailsIndex).Line < document.GetElementbyId("CLASS_TBL_VW_CLASS_SECTION$" + (classIndex + 1)).Line) { string startTime = string.Empty; string endTime = string.Empty; string location = string.Empty; string days = string.Empty; string date = string.Empty; try { startTime = document.GetElementbyId("CLASS_MTG_VW_MEETING_TIME_START$" + detailsIndex).InnerText; endTime = document.GetElementbyId("CLASS_MTG_VW_MEETING_TIME_END$" + detailsIndex).InnerText; location = document.GetElementbyId("DERIVED_SSE_DSP_DESCR40$" + detailsIndex).InnerText; days = document.GetElementbyId("DERIVED_SSE_DSP_CLASS_MTG_DAYS$" + detailsIndex).InnerText; date = document.GetElementbyId("DERIVED_SSE_DSP_START_DT$" + detailsIndex).InnerText; } catch (NullReferenceException) { } CourseOffering courseOffering = new CourseOffering(startTime, endTime, location, days, date); course.AddCourseOffering(courseOffering); detailsIndex++; } } classIndex++; courses.Add(course); mIsLoadingCourses = false; Deployment.Current.Dispatcher.BeginInvoke(() => { OnPropertyChanged("Courses"); }); } foreach (Course course in courses) { if (course.Type == "Lecture") { List <CourseOffering> offerings = course.CourseOfferings; offerings.RemoveAt(offerings.Count - 1); } } Courses = new ObservableCollection <Course>(courses); Deployment.Current.Dispatcher.BeginInvoke(() => { OnPropertyChanged("Courses"); }); Settings.SaveCourses(courses); }