public void LoadFromFile(string name) { //form.textBox1.Text = "HEHE"; feedList = new List <Podcast>(); foreach (string file in Directory.EnumerateFiles(path, name + ".xml")) { XmlReaderSettings settings = new XmlReaderSettings(); settings.DtdProcessing = DtdProcessing.Parse; XmlReader reader = XmlReader.Create(file, settings); SyndicationFeed feed = SyndicationFeed.Load(reader); reader.Close(); foreach (SyndicationItem item in feed.Items) { var podcast = Podcast.CreateNewObject(item.Title.Text, item.Summary.Text, "", "", "", ""); feedList.Add(podcast); } } }
//Laddar in podcast titel och information från url länken till podcast objekt och lägger dem i en List<>(); public void SaveFeeds(string url, string name, string category, string updateTime) { if (ExceptionHandler.CheckNullException(url) && ExceptionHandler.CheckExceptionStringNumber(updateTime) && ExceptionHandler.CheckNullExceptionDot(name) && ExceptionHandler.CheckNullExceptionDot(category)) { System.IO.Directory.CreateDirectory(path); XmlDocument document = new XmlDocument(); document.Load(url); //https://api.sr.se/api/rss/program/2519 File.WriteAllText(path + name + ".xml", document.InnerXml); Podcast podcast = new Podcast("", "", url, name, category, updateTime, DateTime.Now); feedList = new List <Podcast>(); feedList.Add(podcast); var json = new Json(path, name); json.Serialize(feedList); } }
public void LoadFromFile(string url, string name, string category, string updateTime) { feedList = new List <Podcast>(); if (ExceptionHandler.CheckNullException(url) && ExceptionHandler.CheckExceptionStringNumber(updateTime) && ExceptionHandler.CheckNullExceptionDot(name) && ExceptionHandler.CheckNullExceptionDot(category)) { foreach (string file in Directory.EnumerateFiles(path, "*.xml")) { XmlReaderSettings settings = new XmlReaderSettings(); settings.DtdProcessing = DtdProcessing.Parse; XmlReader reader = XmlReader.Create(file, settings); SyndicationFeed feed = SyndicationFeed.Load(reader); reader.Close(); foreach (SyndicationItem item in feed.Items) { var podcast = Podcast.CreateNewObject(item.Title.Text, item.Summary.Text, "", "", "", ""); feedList.Add(podcast); } } } }