ASP.net C#.如何解析博客中的原子供稿 [英] ASP.net c#. How do I parse an atom feed from a blog

查看:68
本文介绍了ASP.net C#.如何解析博客中的原子供稿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

提要位于:

http://latestpackagingnews.blogspot.com/feeds/posts/default

我想要的标签是:

<entry>
    <published></published>
    <title></title>
    <content></content>
</entry>

我什么都不在乎,我想要做的就是循环这些!请不要发布教程链接,我已经尝试了很多,但是根本无法正常工作.请把我当白痴.

I don't care about anything else, all I want to do is loop these! Please don't post tutorial links I've tried a bunch and just can't get any to work. Treat me like an idiot please.

推荐答案

您可以查看System.ServiceModel.Syndication.Atom10FeedFormatter类.(System.ServiceModel.dll)

You can take a look at the System.ServiceModel.Syndication.Atom10FeedFormatter class. (System.ServiceModel.dll)

static void Main(string[] args)
{
    Atom10FeedFormatter formatter = new Atom10FeedFormatter();
    using (XmlReader reader = XmlReader.Create("http://latestpackagingnews.blogspot.com/feeds/posts/default"))
    {
        formatter.ReadFrom(reader);
    }

    foreach (SyndicationItem item in formatter.Feed.Items)
    {
        Console.WriteLine("[{0}][{1}] {2}", item.PublishDate, item.Title.Text, ((TextSyndicationContent)item.Content).Text);
    }

    Console.ReadLine();
}

这篇关于ASP.net C#.如何解析博客中的原子供稿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆