homepage Welcome to WebmasterWorld Guest from 54.204.141.129
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / RSS, ATOM, and Related Technologies
Forum Library, Charter, Moderators: bill & werty

RSS, ATOM, and Related Technologies Forum

    
Creating a dynamic feed
based on an existing dynamic page.
mack




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

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




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

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




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

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / RSS, ATOM, and Related Technologies
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved