public static void XmlOperation(Feed myFeed) { var xmlString = Data.GetXml.getXmlInfo(); //String? var dom = new XmlDocument(); dom.LoadXml(xmlString); // Genererar feeditems som stoppas in i param myFeed foreach (XmlNode item in dom.DocumentElement.SelectNodes("channel/item")) { var title = item.SelectSingleNode("title").InnerText; var description = item.SelectSingleNode("description").InnerText; //var enclosure = item.SelectSingleNode("enclosure"); //var enclosureUrl = enclosure.Attributes["url"].Value; //var itemPubDate = item.SelectSingleNode("pubDate").InnerText; var guid = item.SelectSingleNode("guid").Value; FeedItem myFeedItemTest = new FeedItem(guid, title, description); //FeedItem myFeedItem = new FeedItem(guid, title, enclosureUrl, itemPubDate, description); //myFeed.addFeedItem(myFeedItem); myFeed.addFeedItem(myFeedItemTest); } GUI_TransferInterface.TransmitFeed = myFeed; //// Skapar en ny feedcollection instans som tar emot feeden //FeedCollection fdCollect = new FeedCollection(); //fdCollect.AddFeed(myFeed); }
public void LoadFeed(Data.SerializerItem returFeed) { var feed = new Feed(); AllFeeds.Add(feed); feed.Id = returFeed.Id; feed.Title = returFeed.Title; feed.Url = new Uri(returFeed.Url); returFeed.CollectionFeedItems.ForEach(x => feed.addFeedItem(x.Id, x.Title, new Uri(x.Mp3Url), x.PublishDate, x.IsUsed, x.Description)); feed.setCategory(returFeed.Category.Id, returFeed.Category.Name); feed.UpdateInterval = returFeed.UpdateInterval; }
public static void XmlOperation(Feed myFeed) { var xmlString = Data.GetXml.getXmlInfo(); var dom = new XmlDocument(); if (xmlString != null) { try { dom.LoadXml(xmlString); foreach (XmlNode item in dom.DocumentElement.SelectNodes("channel/item")) { var title = item.SelectSingleNode("title").InnerText; var description = item.SelectSingleNode("description").InnerText; var itemPubDate = item.SelectSingleNode("pubDate").InnerText; var guid = item.SelectSingleNode("guid").Value; string mediaUrl = null; var enclosure = item.SelectSingleNode("enclosure"); if (enclosure != null) { mediaUrl = enclosure.Attributes["url"].Value; } var media = item.SelectSingleNode("media"); if (media != null) { mediaUrl = media.Attributes["url"].Value; } FeedItem myFeedItem = new FeedItem(guid, title, mediaUrl, itemPubDate, description); myFeed.addFeedItem(myFeedItem); } TransferInterface.TransmitFeed = myFeed; } catch { string message = "URL:en måste inkludera en RSS-feed"; bool ERROR = true; TransferInterface.ErrorHandler(ERROR, message); } } else { string message = "Felaktig URL!"; bool ERROR = true; TransferInterface.ErrorHandler(ERROR, message); } }