简体   繁体   English

尝试使用Syndicationitem从RSS feed获得链接

[英]Trying to get links from an RSS feed with Syndicationitem

I am trying to get links from an rss feed like so: 我正在尝试从rss feed获得链接,如下所示:

<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 我的代码循环遍历RSS提要项

    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();' 我已经尝试过'item.links.tostring();' and 'item.link;' 和“ item.link;” and neither seems to work, how can I get the RSS feed's links? 似乎都不起作用,如何获得RSS feed的链接?

you can access links like this: 您可以访问如下链接:

foreach (SyndicationItem item in feed.Items)
{
    string link = item.Links[0].Uri.ToString();
    string text = item.Summary.Text;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM