Welcome to WebmasterWorld Guest from 54.226.189.112

Forum Moderators: bill & werty

Message Too Old, No Replies

Creating a dynamic feed

based on an existing dynamic page.

     

mack

1:25 pm on Mar 22, 2005 (gmt 0)

WebmasterWorld Administrator mack is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Hi all,

I have a site that has a dynamic section that I want to make available as an rss feed.

Lets call the existing page foo.php...

What I have done is to create a file called rss.php that is used to build the actual feed. I have then set the server up to make rss excecute as php and redames this file to feed.rss

I made rss handle like php using the following in htaccess.

<files feed.rss>
ForceType application/x-httpd-php
</files>

On the existing page I have several variables that I want to have included in my feed. we have something like this...

print "a$";
print "b$";

I have changed this to ...

<item>
print "<section-name>a$</section-name>";
print "<section-name>b$</section-name>";
<item>

The main problem is that the variables as well as containing the required info, also contain some markup and html tags. Is there any way of using php to remove the markup? (mainly <b></b> etc.)

I also found that not all variables are displayable in this way. For some I had to use cdata...

<section-name><![CDATA[a$]]></section-name>

Any ideas.

Mack.

encyclo

6:24 pm on Mar 22, 2005 (gmt 0)

WebmasterWorld Senior Member encyclo is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Hi Mack,

Before I start you should bear in mind that I've been doing RSS for a total of only three days, so you should take this advice with a pinch of salt.

What I have done is to create a file called rss.php that is used to build the actual feed. I have then set the server up to make rss excecute as php and redames this file to feed.rss

It's the served mime type which matters more than the file ending (which can be .php, .rss, .xml or whatever). I have this at the top of my PHP-driven RSS feed:

<?php header('Content-type: application/rss+xml; charset=ISO-8859-1');
echo '<?xml version="1.0"?>';?>

(Obviously replace ISO-8859-1 with your preferred charset as required). I'm still not completely up to speed with the debate about

text/xml
versus
application/rss+xml
, but I have a natural tendancy to prefer the latter. You might prefer the former.

Is there any way of using php to remove the markup? (mainly <b></b> etc.)

You could try strip_tags [ca.php.net]. Which version of RSS are you using? As I understand it, Userland RSS 0.92 allows HTML within the

<description>
, whereas Netscape 0.91 or Userland 0.91 only allow plain text (don't even ask about RSS 2.0!).

mack

7:00 pm on Mar 22, 2005 (gmt 0)

WebmasterWorld Administrator mack is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



encyclo thank you very much, nice reply :)

I understand that version 2.0 does allow html tags and it seams to work well with them. The problem is, I don't want to impose and markup onto the feed users, I will try your suggestion for removing the tags and let you know how it goes.

You said you had been working with rss for 2 days.. Same here lol

Thanks again.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month