public static string checkRssConnect(string url) { string title = null; try { RssReader rr = new RssReader(url); title = rr.title; rr.Dispose(); } catch { title = null; } return title; }
/// <summary> /// 対象のXMLが有効かどうか判断する /// </summary> /// <param name="url"></param> public static bool checkRss(string url) { string title = ""; try { RssReader rr = new RssReader(url); title = rr.title; rr.Dispose(); return title != null; } catch { return false; } }
public void updateTopicList(RssReader rr) { int idx = 0; //更新件数チェック if (rr.urlList.Count <= 0) { return; } //ヌチェック if (topicList == null) { topicList = new List<MsgShortNews>(); } //URL1件目チェック if (this.topicList.Count > 0) { //1件目が同じなら未更新と判断 if (this.topicList[0].url.Equals(rr.urlList[0])) { return; } } List<MsgShortNews> newTopicList = new List<MsgShortNews>(); //更新する foreach (string url in rr.urlList) { MsgShortNews n = new MsgShortNews(); try { n.url = url; n.title = rr.urlTitleList[idx]; } catch { Console.WriteLine("ニュース収集エラー"); } newTopicList.Add(n); idx++; } //更新完了 topicList = newTopicList; }
private void onSelect(TreeViewEventArgs e) { LiplisTreeNodeCld cld = null; //クラス名の取得 string className = e.Node.GetType().Name; //ペアレントの取得 if (className == "LiplisTreeNodePar") { } else if (className == "LiplisTreeNodeCld") { cld = (LiplisTreeNodeCld)e.Node; } //ヌルチェック if (cld == null) { return; } //dgvのクリア dgv.Rows.Clear(); int idx = 0; using (RssReader rr = new RssReader(cld.rss.url)) { //dgvの作成 foreach (string title in rr.urlTitleList) { dgv.Rows.Add(new object[] { "", title, rr.dateList[idx], rr.urlList[idx] }); idx++; } } this.Refresh(); }