Reputation: 393
I am trying to get links from an rss feed like so:
<item>
<title>
Mothers CAN wear the same clothes as their daughters
</title>
<link>
http://www.dailymail.co.uk/femail/article-4408430/Mothers-wear-clothes-daughters.html?ITO=1490&ns_mchannel=rss&ns_campaign=1490
</link>
<description>
Stylist Trinny, 53, appeared on This Morning in a pair of white striped culottes from Urban Outfitters that she bought after admiring them on her 13-year-old daughter, Lyla Elichaoff.
</description>
<enclosure url="http://i.dailymail.co.uk/i/pix/2017/04/13/13/3F36FB3200000578-0-image-a-58_1492086235218.jpg" type="image/jpeg" length="9078"/>
<pubDate>Thu, 13 Apr 2017 13:38:02 +0100</pubDate>
<guid>
http://www.dailymail.co.uk/femail/article-4408430/Mothers-wear-clothes-daughters.html?ITO=1490&ns_mchannel=rss&ns_campaign=1490
</guid>
<media:description/>
<media:thumbnail url="http://i.dailymail.co.uk/i/pix/2017/04/13/13/3F36FB3200000578-0-image-a-58_1492086235218.jpg" width="154" height="115"/>
<media:credit scheme="urn:ebu">Ken McKay/ITV/REX/Shutterstock</media:credit>
<media:content type="image/jpeg" url="http://i.dailymail.co.uk/i/pix/2017/04/13/13/3F36FB3200000578-0-image-a-58_1492086235218.jpg"/>
</item>
My code to loop through the rss feed items
private void button2_Click(object sender, EventArgs e)
{
string url = textBox1.Text;
XmlReader reader = XmlReader.Create(url);
SyndicationFeed feed = SyndicationFeed.Load(reader);
reader.Close();
foreach (SyndicationItem item in feed.Items)
{
String subject = item.Links.
articletext.Text = subject;
}
}
I have tried 'item.links.tostring();' and 'item.link;' and neither seems to work, how can I get the RSS feed's links?
Upvotes: 1
Views: 1316
Reputation: 7095
you can access links like this:
foreach (SyndicationItem item in feed.Items)
{
string link = item.Links[0].Uri.ToString();
string text = item.Summary.Text;
}
Upvotes: 3