Jonny922
Jonny922

Reputation: 11

Get Link of RSS

I have a Feed reader and get the title in listbox but how to insert a value link for title?

private void Form1_Load(object sender, EventArgs e)
{
    var reader = XmlReader.Create("http://feeds.feedburner.com/myusername?format=xml");
    var feed = SyndicationFeed.Load<SyndicationFeed>(reader);

    foreach (var item in feed.Items)
    {
       listBox1.Items.Add(item.Title.Text);
       listBox1."add value link" = item.Links."Text";
    }
}

private void listBox1_Click(object sender, EventArgs e)
{          
    MessageBox.Show(listBox1."value link for item selected".ToString());
}

If click on title show the link

Ex: click on my feed2 show wwww/mywebsite/myfeed2

Upvotes: 1

Views: 350

Answers (1)

opewix
opewix

Reputation: 5083

If you want to link rss title and it's url you have to write your own class with title and url properties and write custom item template for listbox or simply define a dictionary.

private Dictionary<string,string> dictionary = new Dictionary<string,string>();

foreach (var item in feed.Items)
        {
            dictionary.Add(item.Title.Text, item.Links.Text);
            listBox1.Items.Add(item.Title.Text);

        }



private void listBox1_Click(object sender, EventArgs e)
  {   
      string url = dictionary[listBox1.SelectedValue];       
      MessageBox.Show(url);
  }

Upvotes: 1

Related Questions