开发者

Displaying wordpress Recent Posts on a .Net site?

I need to display the titles (and perhaps the first line) of some blog 'recent posts' from a Wordpress php site on another website that runs on .Net.

after doing a litt开发者_如何学JAVAle googling I haven't found any definative resources. some have mentioned using RSS.

Can anyone point me in the right direction please.

Cheers!


That's pretty easy using the SyndicationFeed class:

using (var reader = XmlReader.Create("http://someblog.wordpress.com/feed/"))
{
    var feed = SyndicationFeed.Load(reader);
    // Print title and summary of 5 most recent posts
    foreach (var post in feed.Items.Take(5))
    {
        Console.WriteLine ("--- {0} ---", post.Title.Text);
        Console.WriteLine (post.Summary.Text);
        Console.WriteLine();
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜