开发者

Displaying wordpress Recent Posts on a .Net site?

开发者 https://www.devze.com 2023-01-23 00:03 出处:网络
I need to display the titles (and perhaps the first line) ofsome blog \'recent posts\' from a Wordpress php site on another website that runs on .Net.

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

精彩评论

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