Jump to content
xisto Community
Sign in to follow this  
nightfox1405241487

Rss And Php

Recommended Posts

YES! :P

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! :P

GreetingZ



Share this post


Link to post
Share on other sites

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

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

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! :P

 

Thanks again!

 

[N]F

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.