ASP.NET - Need help regarding RSS Feed and wordpress

Asked By Tridip Bhattacharjee
03-Feb-12 06:12 AM

i need to read rss feed from wordpress url. so here is the url http://bbaremancareers.wordpress.com/feed/

i just need to pick up title,content,publish date,title hyperlink url and media file url etc.

i just could fetch only title and content but i need to know how can i fetch also publish date,title hyperlink url and media file url.

here is my code

 protected void Button1_Click(object sender, EventArgs e)
   
{
       
var reader = XmlReader.Create("http://bbaremancareers.wordpress.com/feed/");
       
var feed = SyndicationFeed.Load<SyndicationFeed>(reader);

       
Console.WriteLine("Latest posts from " + feed.Title.Text);

       
foreach (var item in feed.Items)
       
{
           
string strTitle = item.Title.Text;
           
string strContent = item.Summary.Text;
       
}
   
}

so please add more code in my existing code to fetch extra data like publish date,title hyperlink url and media file url from the wordpress url http://bbaremancareers.wordpress.com/feed/.

please help. thanks

  [)ia6l0 iii replied to Tridip Bhattacharjee
03-Feb-12 11:48 AM
It looks like this isn't s normal feed that can be obtained through the SyndicationFeed object. There seems to be some media content elements with the http://search.yahoo.com/mrss/ namespace. 

You should be using XMLReader with XDocument to achieve parsing this. Note that you should place the properties read from the item element into your own entity class.

XNamespace media = "http://search.yahoo.com/mrss/";
using (XmlReader xml = XmlReader.Create("http://bbaremancareers.wordpress.com/feed/"))
{
	XDocument xDoc = XDocument.Load(xml);
    XElement rss   = XElement.Parse(xDoc.ToString());
    var items = rss.Element("channel").Elements("item");
 	foreach (var item in items)
    {
    	string title = item.Element("title").Value;
        string summary = item.Element("description").Value;
        string publishdate = item.Element("pubDate").Value;
        string link = item.Element("link").Value;
        var mediaElement = item.Element(media + "content").Attribute("url");
        string url = mediaElement.Value;
	}
}

Thank you.
  Tridip Bhattacharjee replied to [)ia6l0 iii
06-Feb-12 02:53 AM
good thanks
Create New Account
help
Net hi friends Any one send frequently asked Important questions in C# .Net, ADO .Net, Asp .Net and Sql Server. . . . . . . . tx in Advance. . . . . . Hi, Find this. . (B)What is an IL? (B A) What is scavenging? (B) What are different types of caching using cache object of ASP.NET? (B) How can you cache different version of same page using ASP.NET cache object? (A) How will implement Page Fragment Caching? (B) Can you compare ASP.NET sessions with classic ASP? (B) Which are the various modes of storing ASP.NET session
in Sql server as var_name int How do you separate business logic while creating an ASP.NET application? There are two level of asp.net debugging 1. Page level debugging For this we have to edit the page level debugging The control itself will take care of the date display How can you deploy an asp.net application ? You can deploy an ASP.NET Web application using any one of the following three deployment options. a) Deployment using VS
Migration from ASP to ASP.net How to convert ASP site to ASP.NET site using C# http: / / www.asp.net / downloads / archived-v11 / migration-assistants / asp-to-aspnet hi, ASP.NET framework is very much different from unstrucured ASP and there is no correct way to
Tracing in ASP.NET? hi all, what is tracing? how to achieve tracing in asp.net? different ways of doing tracing? thanks and regards Aman Khan hi. . Tracing in ASP.NET 2.0 Tracing is a way to monitor the execution of your ASP.NET application. You can record exception details and program flow in a way that doesn't
using LINQ The following C# code loads the XML from a local file into an XDocument object. The XDocument is used to select the items to display via its Descendants property in the from loop through every element loaded via the select statement and displayed via the Console object. XDocument xmlDoc = XDocument.Load(@"c:sites.xml"); var q = from c in xmlDoc.Descendants("site") select (string)c custom schema we've defined to store RSS feeds: I could then use the new XDocument class within the System.Xml.Linq namespace to open and query the XML document above. follow this link http: / / weblogs.asp.net / scottgu / archive / 2007 / 08 / 07 / using-linq-to-xml-and-how-to-build-a-custom a file, in-memory XML, or a remote resource accessed via protocols like HTTP. The XDocument class in the System.Xml.Linq namespace includes various methods and properties that simplify working