| |
|
Welcome to AstaHost - Dear Guest | |
Toggle shoutbox
Shoutbox
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Rss And Php
Started by nightfox, Jul 02 2005 06:56 PM
6 replies to this topic
#2
Posted 02 July 2005 - 09:28 PM
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
news.xsl
Try it, it's cool!
GreetingZ
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="http://www.w3.org/1999/XSL/Transform"> <xsl:output 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
#5
Posted 03 July 2005 - 09:03 AM
But rss IS xml!!! For example take a lok at this rdf-file: http://www.ccc.de/up...haosupdates.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
In my example simply replace 'news.rdf' with the file you want to show.
if ($result = xslt_process($xh, 'news.xml', 'news.xsl')
GreetingZ
#6
Posted 04 July 2005 - 03:24 AM
Ok, thanks! I'm going to go try this out now!But rss IS xml!!! For example take a lok at this rdf-file: http://www.ccc.de/up...haosupdates.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
Thanks again!
[N]F
#7
Posted 15 September 2005 - 06:43 AM
This is the easiest RSS Writer script I've seen, give it a try:
Manuel Lemos RSS Writer Class on PHPClasses.org
Maybe 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
Manuel Lemos RSS Writer Class on PHPClasses.org
Maybe 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
Reply to this topic
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











