Click here to Skip to main content
15,917,971 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to create a media Rss feed so that I can use a cooliris plugin to view the images in my SQL database. I have created a standard rss feed and it works, however, I am having trouble creating the media:content tags that the cooliris plugin needs to find the images. This is what I have in my code behind so far. How do I add the media:content tags to WriteElementStrings so that they will show the plugin my image location? Sorry if I am being unclear of what I am asking, but feel free to ask any questions.

Thanks in advance...

As for the code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Text;
using System.Data.SqlClient;
public partial class Pages_MyFeed : System.Web.UI.Page
        string strConnection = "Data Source=Source;User ID=ID;Password=PWD;";
        protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)
            // Clear the response buffer contents
            Response.ContentType = "text/xml";
            XmlTextWriter rssFeed = new XmlTextWriter
            (Response.OutputStream, Encoding.UTF8);
            //writing RSS tags 
            rssFeed.WriteAttributeString("version", "2.0");
            rssFeed.WriteAttributeString("xmlns:media", "");
            rssFeed.WriteAttributeString("xmlns:atom", "");
            rssFeed.WriteElementString("title", "Hat Details");
            rssFeed.WriteElementString("description", "Custom Hat Details");
            rssFeed.WriteElementString("link", "");
            rssFeed.WriteElementString("image", "URL");

            // create sql connection and connect to database
            SqlConnection con = new SqlConnection(strConnection);
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "Find_all";
            cmd.Connection = con;
            SqlDataReader dReader;
            dReader = cmd.ExecuteReader();
            while (dReader.Read())
                string url = "" + dReader["URL"] + ".png";
                rssFeed.WriteElementString("title", dReader["HatName"].ToString());
                rssFeed.WriteElementString("description", dReader["HatName"].ToString());
                rssFeed.WriteElementString("link", url);
                rssFeed.WriteElementString("image", url);
                rssFeed.WriteElementString("pubDate", DateTime.Now.ToString());
Updated 31-Jul-11 9:36am
Herman<T>.Instance 31-Jul-11 15:58pm    
what is in the line
string url = "" + dReader["URL"] + ".png"
the value of dReader["URL"]? does this database field also holds the image name?
what is the value of string url after it is filled? Did you debug the code? Set a breakpoint on the line
and check the value of url.
I3I2UNO 31-Jul-11 16:04pm    
that string is just the location of the images that I want to load into my rss feed. So yes this field holds the image name. It loads all of this correctly into my rss. You can take a look here.
Herman<T>.Instance 31-Jul-11 16:19pm    
if i do click your url i get an image. What kind of behaviour did you expect?
I3I2UNO 31-Jul-11 16:21pm    
I'm trying to create a Media Rss file so that my cooliris plugin can understand where my image is located. The rssFeed.WriteElementString("image", url); does not do this. I need to basically make the rss feed say (media:content url="") (parentheses are supposed to be <>) but I don't know how to emulate this in my code behind.
Herman<T>.Instance 1-Aug-11 3:42am    
look here :

1 solution

So obviously my question is not making much sense so I will try to clarify.

So if you take a look at my current feed here:[^]

You can see the media:content tag. But if you take a look at this feed from flickr:[^]

This feed is in the correct format that my plugin can read. As you can see the media:content tag has additional information within the tag that is different from my feed. Obviously I can accomplish this by writing all of the xml in a static manner, but I want to do this dynamically from my SQL database that I have already created. So my question is this, how can I write my code in my code behind to emulate the media:content tags that are seen in the flickr feed so that my plugin can read my own mRSS feed?
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900