안녕하세요, Visual C# Express에서 RSS 리더를 만들려고합니다. 양식이로드 될 때 rss 피드를 텍스트 상자로 읽어야합니다. RSS 전에 피드와 내가 건너 한 모든 예는 비주얼 스튜디오에서 완료와 나는 일한 적이있다 그리고 내가 이것을 사용하지 못할 것으로 보인다 :Visual C# Express Edition의 RSS 리더
(XmlReader reader = XmlReader.Create(Url))
이것은 내가 지금까지 가지고 것입니다. 작동하지 않습니다.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
var s = RssReader.Read("http://ph.news.yahoo.com/rss/philippines");
textBox1.Text = s.ToString();
}
public class RssNews
{
public string Title;
public string PublicationDate;
public string Description;
}
public class RssReader
{
public static List<RssNews> Read(string url)
{
var webResponse = WebRequest.Create(url).GetResponse();
if (webResponse == null)
return null;
var ds = new DataSet();
ds.ReadXml(webResponse.GetResponseStream());
var news = (from row in ds.Tables["item"].AsEnumerable()
select new RssNews
{
Title = row.Field<string>("title"),
PublicationDate = row.Field<string>("pubDate"),
Description = row.Field<string>("description")
}).ToList();
return news;
}
}
내가 무엇을해야할지 잘 모르겠다. 도와주세요.
텍스트 상자에 무엇을 표시 하시겠습니까? XML 또는 다른 것을 반환 했습니까? – Habib
예, RSS 피드의 텍스트를 표시하고 싶습니다 –