static void Main() { // 1. Find RSS feed // 2. Download RSS as XML GetRSSFile(RSSFeed); // 3. Parse XML to JSON string jsonRSS = GetJSONfromXML(xmlFilePath + xmlFileName); // 4. Print all titels var titles = GetTitles(jsonRSS); foreach (var title in titles) { Console.WriteLine(title); } // 5. JSON to POCO TARSS tarss = GetPOCO(jsonRSS); // 6. Create HTML StringBuilder HTMLasSB = new StringBuilder(); CreateHTMLHEAD(HTMLasSB); CreateHTMLBODY(tarss, HTMLasSB); CreateHTMLFile(HTMLasSB); }
private static TARSS GetPOCO(string jsonRSS) { var jsonRSSobject = JObject.Parse(jsonRSS); var channeJason = jsonRSSobject["rss"]["channel"].ToString(); TARSS tarss = JsonConvert.DeserializeObject <TARSS>(channeJason); return(tarss); }
private static void CreateHTMLBODY(TARSS tarss, StringBuilder HTMLasSB) { HTMLasSB.AppendLine(@"<body>"); HTMLasSB.AppendLine(string.Format("<h1><a href = \"{1}\">{0}</a></h1>", tarss.Title, tarss.Link)); HTMLasSB.AppendLine(@"<ul>"); foreach (var item in tarss.Item) { HTMLasSB.AppendLine(@"<li>"); HTMLasSB.AppendLine(string.Format("<h4><a href = \"{1}\">{0}</a></h4>", item.Title, item.Link)); HTMLasSB.AppendLine(string.Format("<p>{0}</p>", item.Category)); HTMLasSB.AppendLine(@"</li>"); } HTMLasSB.AppendLine(@"<ul>"); HTMLasSB.AppendLine(@"</body>"); }