private CategoriesList BuildCategories() { CategoriesList categoriesList = new CategoriesList(); try { string filepath = System.Web.Hosting.HostingEnvironment.MapPath("~/data/Categories.xml"); XmlDocument xmlDocument = new XMLConnector().GetXMLDocument(filepath); XmlNodeList categoryNodes = xmlDocument.SelectNodes("categories/category"); if (categoryNodes != null) { foreach (XmlNode categoryNode in categoryNodes) { string id = categoryNode.Attributes["id"].Value; CategoryItem categoryItem = new CategoryItem(id); categoryItem.Title = categoryNode.Attributes["title"].Value; XmlNodeList providerMappingsNodes = categoryNode.SelectNodes("provider-mappings/provider-mapping"); if (providerMappingsNodes != null) { ProviderMappingList providerMappingList = categoryItem.ProviderMappingList; foreach (XmlNode providerMappingNode in providerMappingsNodes) { ProviderMapping providerMapping = new ProviderMapping(); providerMapping.Provider = (ProviderEnum) Enum.Parse(typeof(ProviderEnum), providerMappingNode.Attributes["id"].Value); providerMapping.Category = providerMappingNode.Attributes["category"].Value; providerMappingList.Add(providerMapping); } } XmlNodeList topicsNodes = categoryNode.SelectNodes("topics/topic"); if (topicsNodes != null) { TopicList topicList = categoryItem.TopicList; foreach (XmlNode topicNode in topicsNodes) { string title = topicNode.Attributes["title"].Value; TopicItem topicItem = new TopicItem(title, title); topicList.Add(topicItem); } } categoriesList.Add(categoryItem); } } } catch (Exception exception) { ErrorService.Log("CategorizationService", "BuildCategories", null, exception); } return categoriesList; }
private void DisplayCategory(CategoryItem categoryItem) { Response.Write("<div class=\"categoryBlock\">"); Response.Write("<div class=\"categoryTitle\"><h2>" + categoryItem.Title + "</h2></div>"); Response.Write("<div class=\"categoryBulletList\">"); Response.Write("<ul>"); TopicList topicList = categoryItem.TopicList; foreach (TopicItem topicItem in topicList) { DisplayTopic(topicItem); } Response.Write("</ul>"); Response.Write("</div>"); Response.Write("</div>"); }