public static FeedINfo createFromRssXml(XmlDocument doc) { FeedINfo result = new FeedINfo(); XmlNode root = doc.DocumentElement; result.title = root.SelectSingleNode("channel/title").InnerText; result.link = root.SelectSingleNode("channel/link").InnerText; result.description = root.SelectSingleNode("channel/description").InnerText; result.copyright = root.SelectSingleNode("channel/copyright").InnerText; result.language = root.SelectSingleNode("channel/language").InnerText; result.pubDate = Convert.ToDateTime(root.SelectSingleNode("channel/pubDate").InnerText); result.lastBuildDate = Convert.ToDateTime(root.SelectSingleNode("channel/lastBuildDate ").InnerText); result.image = CreateImageInfoFromXmlNode(root.SelectSingleNode("channel/image")); result.items = CreateItemInfoListFromXmlNodes(root.SelectNodes("//channel/item")); return(result); }
public static FeedINfo GetData() { //List<ItemInfo> result = new List<Event>(); XmlDocument doc = null; if (File.Exists("StoryRss1854.xml")) { try { doc = new XmlDocument(); doc.Load("StoryRss1854.xml"); } catch (Exception) { doc = null; File.Delete("StoryRss1854.xml"); } } if (File.Exists("StoryRss1854.xml") && DateTime.Now.Subtract(File.GetCreationTime("StoryRss1854.xml")).TotalSeconds > maxTimeout.TotalSeconds) { doc = null; File.Delete("StoryRss1854.xml"); } if (!File.Exists("StoryRss1854.xml")) { WebClient webClient = new WebClient(); webClient.DownloadFile("http://www.ynet.co.il/Integration/StoryRss1854.xml", @"StoryRss1854.xml"); } if (doc == null) { doc = new XmlDocument(); doc.Load("StoryRss1854.xml"); } FeedINfo info = FeedInfoUtils.createFromRssXml(doc); return(info); //List<Event> }