neo926 Posted July 20, 2006 Share Posted July 20, 2006 So, I'm creating an RSS feed for a site. It includes PHP code, as it pulls all the latest articles from the site's MySQL database when creating the feed. However, when I display the XML file, it hasn't processed any of the PHP code I have in the feed. Basically, my code looks like this:[code]<?php header('Content-type: text/xml'); ?><rss version="2.0"><channel><title>Title</title><description>Description</description><link>http://link.com/</link><copyright>All material copyright 2006 their respective owners</copyright><?phpPHP code pulls data from db?> <item> <title> <?php echo $myrow['title']; ?></title> <description> <?php echo $myrow['teaser']; ?></description> <link>http://link.com/index.php?id=<?php echo $myrow['id']; ?></link> </item> <?php}?></channel></rss>[/code]Now, I know this feed works, as it's basically the same code I have on a different site, and there are no problems displaying the RSS feed. On this site, however, when you click on the XML link, it takes you to the XML page, only all the PHP code is sitting there, completely unparsed.Is there something the site's server might not be capable of doing that is causing this problem? Or am I not including something I should be? Help! Quote Link to comment https://forums.phpfreaks.com/topic/15105-including-php-in-an-rss-feed/ Share on other sites More sharing options...
neo926 Posted July 20, 2006 Author Share Posted July 20, 2006 Did I post this in the wrong forum? Quote Link to comment https://forums.phpfreaks.com/topic/15105-including-php-in-an-rss-feed/#findComment-60978 Share on other sites More sharing options...
helppingme Posted July 20, 2006 Share Posted July 20, 2006 Go here for RSS & XML reader source code..http://www.phpfreaks.com/forums/index.php/topic,101240.0.html Quote Link to comment https://forums.phpfreaks.com/topic/15105-including-php-in-an-rss-feed/#findComment-60983 Share on other sites More sharing options...
trq Posted July 20, 2006 Share Posted July 20, 2006 [quote]Go here for RSS & XML reader source code..[/quote]He is creating a feed, not a feed reader.What file extension does this file have? In order to parse the php it'll either need the .php extension, or you'll need to setup your server to parse .xml as php. Quote Link to comment https://forums.phpfreaks.com/topic/15105-including-php-in-an-rss-feed/#findComment-60986 Share on other sites More sharing options...
helppingme Posted July 20, 2006 Share Posted July 20, 2006 Sorry for the post before, here is a php source code to parse XML.[code]<?php header("Content-Type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"; echo "<?xml-stylesheet href=\"/style/xml.css\" type=\"text/css\"?>";echo "<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\""; echo " \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">"; echo "<rss version=\"0.91\">"; echo "<channel>"; echo "<title>".htmlspecialchars($sitename)."</title>"; echo "<link>$siteurl</link>"; echo "<description>".htmlspecialchars($description)."</description>"; echo "<language>$xml_language</language>";echo "<item>"; echo "<title>".htmlspecialchars($products_name)."</title>\n"; echo "<link>$siteurl$products</link>\n";echo "<description>".htmlspecialchars($productdescription)."</description>\n";echo "<price>$price_format</price>\n";echo "</item>\n";} echo "</channel>\n"; echo "</rss>"; ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15105-including-php-in-an-rss-feed/#findComment-61001 Share on other sites More sharing options...
neo926 Posted July 20, 2006 Author Share Posted July 20, 2006 [quote author=thorpe link=topic=101190.msg400407#msg400407 date=1153402486][quote]Go here for RSS & XML reader source code..[/quote]He is creating a feed, not a feed reader.What file extension does this file have? In order to parse the php it'll either need the .php extension, or you'll need to setup your server to parse .xml as php.[/quote]I had it as an .xml file. What do I need to do to parse .xml as php? Quote Link to comment https://forums.phpfreaks.com/topic/15105-including-php-in-an-rss-feed/#findComment-61421 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.