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();
}
}
精彩评论