<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jesal gadhia &#187; LINQ</title>
	<atom:link href="http://jesal.us/tag/linq/feed/" rel="self" type="application/rss+xml" />
	<link>http://jesal.us</link>
	<description></description>
	<lastBuildDate>Thu, 14 Jul 2011 18:51:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to parse WordPress RSS feed using LINQ</title>
		<link>http://jesal.us/2010/03/how-to-parse-wordpress-rss-feed-using-linq/</link>
		<comments>http://jesal.us/2010/03/how-to-parse-wordpress-rss-feed-using-linq/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 05:32:28 +0000</pubDate>
		<dc:creator>J</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://jesal.us/?p=238</guid>
		<description><![CDATA[Here&#8217;s a code snippet of parsing a typical WordPress RSS feed using LINQ. Note, we have to skip the first image from the media element since that&#8217;s usually a gravatar of the author. Everything else is pretty straight forward. private void BindBlogFeed() { XDocument doc = XDocument.Load("http://blogworkseverytime.wordpress.com/feed/"); XNamespace content = "http://purl.org/rss/1.0/modules/content/"; XNamespace media = "http://search.yahoo.com/mrss/"; [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a code snippet of parsing a typical WordPress RSS feed using LINQ. Note, we have to skip the first image from the media element since that&#8217;s usually a gravatar of the author.</p>
<p>Everything else is pretty straight forward.</p>
<pre>
    private void BindBlogFeed()
    {
        XDocument doc = XDocument.Load("http://blogworkseverytime.wordpress.com/feed/");
        XNamespace content = "http://purl.org/rss/1.0/modules/content/";
        XNamespace media = "http://search.yahoo.com/mrss/";

        var query = (from feed in doc.Descendants("item")
                     orderby DateTime.Parse(feed.Element("pubDate").Value) descending
                     select new
                     {
                         Title = feed.Element("title").Value,
                         Description = HttpUtility.HtmlDecode(feed.Element("description").Value),
                         Content = HttpUtility.HtmlDecode(feed.Element(content.GetName("encoded")).Value),
                         Image = (from img in feed.Elements(media.GetName("content"))
                                  where img.Attribute("url").Value.Contains("gravatar") == false
                                  select img.Attribute("url").Value).FirstOrDefault() ?? "",
                         Link = feed.Element("link").Value,
                         Date = DateTime.Parse(feed.Element("pubDate").Value).ToShortDateString()
                     });

        lvFirstBlogFeed.DataSource = query.Take(1).ToList();
        lvFirstBlogFeed.DataBind();

        lvRemainingBlogFeed.DataSource = query.Skip(1).ToList();
        lvRemainingBlogFeed.DataBind();
    }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jesal.us/2010/03/how-to-parse-wordpress-rss-feed-using-linq/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

