+ g_strfreev(timesArray);
+
+ return resultList;
+}
+
+
+GList* getMovieList(xmlNodePtr movieSideDiv)
+{
+
+ xmlNodePtr nav = movieSideDiv->children;
+ xmlNodePtr tmp1, tmp2, tmp3 = NULL;
+
+ GList* resultList = NULL;
+
+ while(nav != NULL) {
+ tmp1 = getFirstSiblingByAttributeValue(nav, "class", "movie", 5);
+ if (tmp1 != NULL) { //is a movie
+ Movie* m = malloc(sizeof(Movie));
+ tmp2 = getFirstChildByAttributeValue(tmp1, "class", "name", 4);
+ if ((tmp2 != NULL) && (tmp2->children != NULL) && (tmp2->children->children != NULL)) { //<div class="name"><a><span/>
+ m->title = xmlNodeGetContent(tmp2->children->children);
+ }
+ tmp2 = getFirstChildByAttributeValue(tmp1, "class", "info", 4);
+ if (tmp2 != NULL) {
+ m->info = xmlNodeGetContent(tmp2);
+ }
+ tmp2 = getFirstChildByAttributeValue(tmp1, "class", "times", 5);
+ if (tmp2 != NULL) {
+ gchar* showtimesStr = xmlNodeGetContent(tmp2);
+ GList* showtimes = getShowtimes(showtimesStr);
+ free(showtimesStr);
+ m->showTimes = showtimes;
+ }
+ resultList = g_list_append(resultList, m);
+ }
+
+ nav = nav->next;
+ }
+
+ return resultList;
+}
+
+GList* getTheaterMovies(Theater* t)
+{
+
+ /*
+ * <div class="theater">
+ * <div class="desc"/>
+ * <div class="showtimes">
+ * <div class="show_left">
+ * <div class="movie/>
+ * ...
+ * </div>
+ * <div class="show_right">
+ * <div class="movie"/>
+ * ...
+ * </div>
+ * </div>
+ * </div>
+ */
+
+ GList* left = NULL;
+ GList* right = NULL;
+ xmlNodePtr showtimesDiv = getFirstChildByAttributeValue(t->data, "class", "showtimes", 9);
+ if (showtimesDiv != NULL) {
+
+ xmlNodePtr showLeft = getFirstChildByAttributeValue(showtimesDiv, "class", "show_left", 9);
+ if (showLeft != NULL)
+ left = getMovieList(showLeft);
+
+ xmlNodePtr showRight = getFirstChildByAttributeValue(showtimesDiv, "class", "show_right", 10);
+ if (showRight != NULL)
+ right = getMovieList(showRight);
+
+ return g_list_concat(left, right);
+
+ }
+
+
+}
+
+
+void deleteShowTime(ShowTime* st)
+{
+ free(st->time);
+ free(st);
+}
+
+
+void deleteShowTimeList(GList * showTimeList)
+{
+ g_list_foreach(showTimeList, (GFunc) deleteShowTime, NULL);
+ g_list_free(showTimeList);
+}
+
+
+void deleteMovie(Movie* m)
+{
+ free(m->title);
+ free(m->info);
+ deleteShowTimeList(m->showTimes);
+ free(m);
+}
+
+
+void deleteMovieList(GList* movieList)
+{
+ g_list_foreach(movieList, (GFunc) deleteMovie, NULL);
+ g_list_free(movieList);
+}
+
+
+void deleteTheater(Theater* t)
+{
+ free(t->name);
+ free(t->address);
+ free(t);
+}
+
+void deleteTheaterList(GList* theaterList)
+{
+ g_list_foreach(theaterList, (GFunc) deleteTheater, NULL);
+ g_list_free(theaterList);
+}
+
+
+void showTime(ShowTime* st, gpointer nothing)
+{
+ printf("%s ", st->time);
+}
+
+void showMovie(Movie* m, gpointer nothing)
+{
+ printf(" Title = %s\n", m->title);
+ printf(" Info = %s\n", m->info);
+ printf(" Schedule = ");
+ g_list_foreach(m->showTimes, (GFunc) showTime, NULL);
+ printf("\n");
+}
+
+
+void showTheater(Theater * t, gpointer nothing)
+{
+ printf("Name = %s\n", t->name);
+ printf("Info = %s\n", t->address);
+ GList* movieList = getTheaterMovies(t);
+ g_list_foreach(movieList, (GFunc) showMovie, NULL);
+ deleteMovieList(movieList);
+ printf("\n");