nightfox1405241487 0 Report post Posted July 2, 2005 I have a news feed I'd like to display on a PHP page. I know PHP-Nuke has built in RSS feeds that you can display a feed with, but does anyone know how to take a RSS feed and display it using PHP?Thanks![N]F Share this post Link to post Share on other sites
hazeshow 0 Report post Posted July 2, 2005 YES! In this example there is the rss-newsfeed-file called 'news.rdf', the stylesheet, in my case an xsl-stylesheet 'news.xsl' and the php-code which tells the server to throw the rdf-file against the xsl-file 'news.php'. Code goes like this:news.php [b][i]<?php$xh = xslt_create();if ($result = xslt_process($xh, 'news.rdf', 'news.xsl')) { echo $result;xslt_free($xh);}else {echo "<p>";echo xslt_error($xh);echo xslt_errno($xh);echo "</p>";xslt_free($xh);}?>[/i][/b] news.xsl [b][i]<xsl:stylesheet version="1.0" xmlns:xsl="www.w3.org/1999/XSL/Transform/" method="html"/><xsl:template match="/"><xsl:for-each select="rss/channel/item"> <DIV STYLE="color:gray; font-size:10px; font-family:verdana"><a><xsl:attribute name="href"><xsl:value-of select="link"/></xsl:attribute> <xsl:attribute name="target"><xsl:value-of select="title"/></xsl:attribute> <xsl:value-of select="title"/></a></DIV></xsl:for-each> </xsl:template></xsl:stylesheet>[/i][/b] For doing it this way the XSLT support (Sablotron) has got to be enabled. Depending on your server configuration you might have to write the complete path for the filenames in the php-code, like '/htdocs/blabla ../news.rdf'Try it, it's cool! GreetingZ Share this post Link to post Share on other sites
nightfox1405241487 0 Report post Posted July 3, 2005 know how to do it for XML?[N]F Share this post Link to post Share on other sites
runefantasy 0 Report post Posted July 3, 2005 Search GOOGLE... It has lots of stuff on it and quite a few scripts... I got mine from there, but lost it when there was this dDOS attack on my last server... I think I got it on my backup but it's on a different computer Share this post Link to post Share on other sites
hazeshow 0 Report post Posted July 3, 2005 But rss IS xml!!! For example take a lok at this rdf-file: http://www.ccc.de/rss/updates.rdf , this IS pure xml.data! It's doesn't matter whether your data comes from a file 'news.xml' or 'news.rdf' as long as the content is well-formed xml. In my example simply replace 'news.rdf' with the file you want to show. if ($result = xslt_process($xh, 'news.xml', 'news.xsl') GreetingZ Share this post Link to post Share on other sites
nightfox1405241487 0 Report post Posted July 4, 2005 But rss IS xml!!! For example take a lok at this rdf-file: http://www.ccc.de/rss/updates.rdf , this IS pure xml.data! It's doesn't matter whether your data comes from a file 'news.xml' or 'news.rdf' as long as the content is well-formed xml. In my example simply replace 'news.rdf' with the file you want to show. if ($result = xslt_process($xh, 'news.xml', 'news.xsl') GreetingZ <{POST_SNAPBACK}> Ok, thanks! I'm going to go try this out now! Thanks again! [N]F Share this post Link to post Share on other sites
jvizueta 0 Report post Posted September 15, 2005 This is the easiest RSS Writer script I've seen, give it a try:Manuel Lemos RSS Writer Class on PHPClasses.orgMaybe you don't want a php script but you want to learn the whole logic of RSS, anyway this script can be useful to you, read it, it's easy Share this post Link to post Share on other sites