$(document).ready(function() { $("#rssURL").val("http://feeds.encosia.com/Encosia"); loadData(); }); function loadData() { $("#feedContainer").empty(); $.get("FeedServer.ashx?url=" + $("#rssURL").val(), function(data) { $(data).find('item').each(function() { var $item = $(this); var title = $item.find('title').text(); var link = $item.find('link').text(); var description = $item.find('description').text(); var pubDate = $item.find('pubDate').text(); var html = "<div style=\"margin-bottom:8px;\">"; html += "<h3>" + title + "</h3>"; html += "<em>" + pubDate + "</em>"; html += "<p>" + description + "</p>"; html += "<a href=\"" + link + "\" target=\"_blank\">Read More</a>"; html += "</div>"; $('#feedContainer').append(html); }); }); }
<%@ WebHandler Language="C#" Class="FeedServer" %> using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.Services; using System.Xml.Linq; public class FeedServer : IHttpHandler { public void ProcessRequest (HttpContext context) { string url = context.Request.QueryString["url"]; XDocument feedXML = XDocument.Load(url); context.Response.ContentType = "text/xml"; context.Response.Write(feedXML.ToString()); } }