Jump to content

PHP and RSS


scott100
 Share

Recommended Posts

I am working on a project and would like to include an RSS feed. Using php, i want to grab the rss contents and convert them to html.Say i had a news feed like so: http://newsrss.bbc.co.uk/rss/newsonline_uk...cotland/rss.xmlDoes anyone have some code that would do this conversion?Any thoughts etc are also welcome. :)

Link to comment
Share on other sites

There is no pre made code for converting RSS to (X)HTML. That's actually the whole point of having RSS instead of an (X)HTML microformat for news - to allow you to use, or not use the data in any way you'd like.You can turn an RSS feed into (X)HTML by the same means by which you can convert XML data (RSS is such type of data) to (X)HTML. This includes, but is not limited to, XSLT, SimpleXML, DOM, XMLReader, etc.In addition, because RSS is a standard after all (well... not a unified one really. I mean there are 3 independant versions + Atom), PEAR's XML_RSS

Link to comment
Share on other sites

Maybe i should have said, the RSS is not stored on my server, it is coming from sites such as the BBC. I want to take that content and display it on my web pages.From what i remember the path to the xslt is saved in the xml file, but i don't have access to this file...Hope this is clear. :)EDITI done some searching and found exactly what i needed, a free script and the file sizes are smallhttp://www.extralabs.net/feed2html.htmHappy days :)

Link to comment
Share on other sites

Maybe i should have said, the RSS is not stored on my server, it is coming from sites such as the BBC. I want to take that content and display it on my web pages.From what i remember the path to the xslt is saved in the xml file, but i don't have access to this file...Hope this is clear. :)
You have PHP, so you don't need that. You have more power at your fingertips. I mean just look at the XSLT link from my first post. You can execute the transformation with PHP so that you give the browser only the final (X)HTML. You could use the following 4 lines to execute an XSLT tranformation with a known XSLT file over a specified XML and echo the result.
<?php$proc = new XSLTProcessor;$proc->importStylesheet(DOMDocument::load('xsltFileForRssProcessing.xsl'));echo $proc->transformToXML(DOMDocument::load('http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/scotland/rss.xml'));?>

That is, if you have the XSL extension. If you can enable it yourself, see question 6 from the XSLT FAQ. If not, ask your host how (if) you can enable this extension.If enabling it is not an option for whatever reason, make sure you have at least any of the other extensions available.

Link to comment
Share on other sites

<?php$proc = new XSLTProcessor;$proc->importStylesheet(DOMDocument::load('xsltFileForRssProcessing.xsl'));echo $proc->transformToXML(DOMDocument::load('http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/scotland/rss.xml'));?>

That's some interesting stuff boen_robot, i will try it out tomorrow.thanks
Link to comment
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
 Share

×
×
  • Create New...