Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. RSS Aggregator

RSS Aggregator

Scheduled Pinned Locked Moved C#
databasexmlhelpannouncement
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mil_an
    wrote on last edited by
    #1

    Hi, I'm trying to create a RSS News Aggregator, and this is part of code for it: private void Page_Load(object sender, System.EventArgs e) { // See if the news items for this feed are in the Data Cache string strFeedID = Request.QueryString["FeedID"]; int feedID = 0; if (strFeedID != null) { feedID = Int32.Parse(strFeedID); } XmlDocument feedXML = (XmlDocument) Cache["Feed" + feedID]; if (feedXML == null) { // item not found in cache, get the feed details // Connect to the Database OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Inetpub\\wwwroot\\SyndicationDemo\\RSS.mdb"); // Retrieve the SQL query results string SQL_QUERY = "SELECT URL, UpdateInterval FROM Feeds WHERE FeedID = @FeedID"; OleDbCommand myCommand = new OleDbCommand(SQL_QUERY, myConnection); OleDbParameter feedParam = new OleDbParameter("@FeedID", OleDbType.Integer, 4); feedParam.Value = feedID; myCommand.Parameters.Add(feedParam); myConnection.Open(); string feedURL = ""; int updateInterval = 0; OleDbDataReader reader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); reader.Read(); try { feedURL = reader["URL"].ToString(); updateInterval = Int32.Parse(reader["UpdateInterval"].ToString()); } catch { feedURL = "default url"; updateInterval = 0; // or any other default value } myConnection.Close(); // Now that we have the feed URL, load it in into an XML document feedXML = new XmlDocument(); feedXML.Load(feedURL); Cache.Insert("Feed" + feedID, feedXML, null, DateTime.Now.AddMinutes(updateInterval), TimeSpan.Zero); } xmlNewsItems.Document = feedXML; // Add the FeedID parameter to the XSLT stylesheet XsltArgumentList xsltArgList = new XsltArgumentList(); xsltArgList.AddParam("FeedID", "", feedID); xmlNewsItems.TransformArgumentList = xsltArgList; } ____________________________________________________ I am receiving this error when I tr

    H 1 Reply Last reply
    0
    • M mil_an

      Hi, I'm trying to create a RSS News Aggregator, and this is part of code for it: private void Page_Load(object sender, System.EventArgs e) { // See if the news items for this feed are in the Data Cache string strFeedID = Request.QueryString["FeedID"]; int feedID = 0; if (strFeedID != null) { feedID = Int32.Parse(strFeedID); } XmlDocument feedXML = (XmlDocument) Cache["Feed" + feedID]; if (feedXML == null) { // item not found in cache, get the feed details // Connect to the Database OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Inetpub\\wwwroot\\SyndicationDemo\\RSS.mdb"); // Retrieve the SQL query results string SQL_QUERY = "SELECT URL, UpdateInterval FROM Feeds WHERE FeedID = @FeedID"; OleDbCommand myCommand = new OleDbCommand(SQL_QUERY, myConnection); OleDbParameter feedParam = new OleDbParameter("@FeedID", OleDbType.Integer, 4); feedParam.Value = feedID; myCommand.Parameters.Add(feedParam); myConnection.Open(); string feedURL = ""; int updateInterval = 0; OleDbDataReader reader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); reader.Read(); try { feedURL = reader["URL"].ToString(); updateInterval = Int32.Parse(reader["UpdateInterval"].ToString()); } catch { feedURL = "default url"; updateInterval = 0; // or any other default value } myConnection.Close(); // Now that we have the feed URL, load it in into an XML document feedXML = new XmlDocument(); feedXML.Load(feedURL); Cache.Insert("Feed" + feedID, feedXML, null, DateTime.Now.AddMinutes(updateInterval), TimeSpan.Zero); } xmlNewsItems.Document = feedXML; // Add the FeedID parameter to the XSLT stylesheet XsltArgumentList xsltArgList = new XsltArgumentList(); xsltArgList.AddParam("FeedID", "", feedID); xmlNewsItems.TransformArgumentList = xsltArgList; } ____________________________________________________ I am receiving this error when I tr

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      The exception is pretty obvious: the path you're requesting can't be found. When you want to load a file, you must use the physical path - not the URL. In ASP.NET, you can use MapPath (implemented on the Page and HttpServerUtility (the Server property that many classes expose)) to map a virtual path (i.e., URL) to a physical path on the same machine:

      feedURL = MapPath("default url");

      That'll get you the physical path to the file which you can load into your XmlDocument.

      Microsoft MVP, Visual C# My Articles

      M 1 Reply Last reply
      0
      • H Heath Stewart

        The exception is pretty obvious: the path you're requesting can't be found. When you want to load a file, you must use the physical path - not the URL. In ASP.NET, you can use MapPath (implemented on the Page and HttpServerUtility (the Server property that many classes expose)) to map a virtual path (i.e., URL) to a physical path on the same machine:

        feedURL = MapPath("default url");

        That'll get you the physical path to the file which you can load into your XmlDocument.

        Microsoft MVP, Visual C# My Articles

        M Offline
        M Offline
        mil_an
        wrote on last edited by
        #3

        Hi, Thanks for your feedback. This section of the aggregator should initially display a blank page, and not anything else (including any other URL's). Do you know how I could go about rectifying that? Thanks once again :)

        H 1 Reply Last reply
        0
        • M mil_an

          Hi, Thanks for your feedback. This section of the aggregator should initially display a blank page, and not anything else (including any other URL's). Do you know how I could go about rectifying that? Thanks once again :)

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          1. Set all controls' Visible properties to false that you don't want displayed. 2. Override Render in your page and don't render anything initially. 3. Redirect to a blank page. 4. Transfer execution to a blank page. 5. ... There's countless ways.

          Microsoft MVP, Visual C# My Articles

          M 1 Reply Last reply
          0
          • H Heath Stewart

            1. Set all controls' Visible properties to false that you don't want displayed. 2. Override Render in your page and don't render anything initially. 3. Redirect to a blank page. 4. Transfer execution to a blank page. 5. ... There's countless ways.

            Microsoft MVP, Visual C# My Articles

            M Offline
            M Offline
            mil_an
            wrote on last edited by
            #5

            Thanks Heath :)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups