Page 1 of 1

Creating an RSS FEED

Posted: Wed Aug 20, 2008 5:52 pm
by psychotomus
http://validator.w3.org/feed/check.cgi? ... 2Ffeed.rss = my validation. don't really understyand what is wrong with it.

help please.don't know what iswrong.
my code:

Code: Select all

 
        //create rss feed
$str = '<?xml version="1.0" encoding="utf-8"?>
        <rss version="2.0">
        <channel>';
        $result = mysql_query("SELECT * FROM themes WHERE pending='n' ORDER BY id DESC LIMIT 10");
        while($themes = mysql_fetch_object($result))
        {
        $descr = '<div class="entry">
                <p>
                    <img src="images/arrow.png" alt="" /> Name: <a href="' . $siteURL . "/themes/" . $themes->id . "/" .  clean_url($themes->name) . '/">' .  $themes->name . '</a><br />
                    <img src="images/arrow.png" alt="" /> Author: <a href="' . $siteURL . "/author.php?id=" . $themes->username . '">' . $themes->username . '</a><br />
 
                    <img src="images/arrow.png" alt="" /> Categories: ' . theme_cats($themes->id) . '<br />
                    <img src="images/arrow.png" alt="" /> Properties: <br />' .
                    theme_properties($themes->id) . '
                </p>
                <div class="demo">';
                
                 if(!is_dir("../testrun/wp-content/themes/$themes->id/"))
                 { 
                    $descr .=  'Demo (#)';
                } else 
                {
                    $descr .= '<a href="' . $siteURL . '/testrun/index.php?preview_theme=' . $themes->id . '" target="_blank" class="style1">Demo (#)</a>';
                } 
                $descr .= '</div> ';
        $str .= "
<item>
<title>$thems->name WP Theme</title>
<link>" . $siteURL . "/themes/" . $themes->id . "/" .  clean_url($themes->name) . "</link>
<guid>" . $siteURL . "/themes/" . $themes->id . "/" .  clean_url($themes->name) . "</guid>
<pubDate>" . date("D M j G:i:s T Y")   . "</pubDate>
<description>[CDATA[ " .     $descr      . "  ]]</description>
</item>";
        }
$str .= '</channel>
</rss>';
        $fp = fopen('../feed.rss', 'w');
        fwrite($fp, $str);
        fclose($fp);
 

Re: Creating an RSS FEED

Posted: Wed Aug 20, 2008 9:22 pm
by zootboy
Ya know, I don't think rss feed content is supposed to contain any html. I believe it should be plain text only, like this:

Code: Select all

 
<?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="2.0">
  <channel>
    <title>MY SITE</title>
    <link>http://www.example.com</link>
    <description>My website. I put stuff on it.</description>
    <item>
       <title>August 4, 2008 - NEWS</title>
       <link>http://www.example.com/news</link>
       <description>News has been posted!</description>
    </item>
  </channel>
</rss>
 

Re: Creating an RSS FEED

Posted: Wed Aug 20, 2008 9:34 pm
by Christopher
You might be able to use CDATA to put HTML is a block:

Code: Select all

<description>
<![CDATA[
<p>
<!-- Your HTML here -->
</p>
]]>
</description>

Re: Creating an RSS FEED

Posted: Thu Aug 21, 2008 9:10 am
by zootboy
Even if it were possible to put HTML in rss feeds, most rss readers would ignore it. Rss feeds are supposed to be plain text, in my understanding. Here's the wikipedia article on it: http://en.wikipedia.org/wiki/RSS

As for the CDATA thing, did you look at the validation page? It has CDATA tags in it, but it still fails because of the HTML within the tags. It would appear that they do nothing.

Re: Creating an RSS FEED

Posted: Fri Aug 22, 2008 10:32 pm
by psychotomus
I thought rss feeds was allows to have html tags?

Re: Creating an RSS FEED

Posted: Sat Aug 23, 2008 10:11 am
by zootboy
Do you know what rss feeds are used for? They are supposed to be small, plain text news updates that link to a webpage. Even if you could put html in them, most rss readers would not process it.