Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  yordan : (19 June 2013 - 02:28 PM) Long Life To Asta New Era
@  agyat : (19 June 2013 - 01:58 PM) New Era Start At Asta Or Asta Start In New Era. :unsure:
@  yordan : (16 June 2013 - 05:41 PM) You're Welcome, Agyat!
@  agyat : (16 June 2013 - 07:38 AM) Thanks Yordan...
@  velma : (16 June 2013 - 12:06 AM) I Have Asked Opa To Check For A Backup.. He'll Let Me Know Soon :)
@  velma : (16 June 2013 - 12:05 AM) T_T It Seems That Someone Has Deleted That Topic Since I Found The Url Of The Topic But It Gives Me An Error
@  yordan : (15 June 2013 - 10:31 PM) @velma : It's A Tuto On How To Create A Login Program.
@  yordan : (15 June 2013 - 10:31 PM) Happy Birthday To Youuuuuu Agyat!
@  yordan : (15 June 2013 - 10:31 PM) Ba$
@  agyat : (15 June 2013 - 04:41 PM) :(
@  agyat : (15 June 2013 - 04:41 PM) Where The Hall I Were? 15Th Is Almost At End And No-One Wished Me "happy Birthday"!!!
@  velma : (14 June 2013 - 10:39 AM) Which Tutorial Is He Searching For?
@  velma : (14 June 2013 - 10:38 AM) Which Tutorial Is He Searching For?
@  yordan : (14 June 2013 - 07:47 AM) Ok, Have A Look Tomorrow.
@  yordan : (13 June 2013 - 03:19 PM) @velma, Can You Have A Look At Feelay's Problem? Seems That His Tutorial Is Not Searchable Today.
@  Feelay : (13 June 2013 - 08:11 AM) Oh, Haha
@  velma : (12 June 2013 - 05:39 PM) T_T Lately My Levels Of Procrastination..... **sigh**
@  velma : (12 June 2013 - 05:38 PM) I'll Do It Later
@  velma : (12 June 2013 - 05:38 PM) Procrastinators.. People Who Keep Saying "i'll Do This In A Bit"
@  Feelay : (12 June 2013 - 02:05 PM) Deal Punishments To What?

Photo
- - - - -

Rss And Php


6 replies to this topic

#1 nightfox

nightfox

    NiGHTFoX - Hiding in the dark

  • Members
  • 680 posts

Posted 02 July 2005 - 06:56 PM

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

#2 hazeshow

hazeshow

    Premium Member

  • Members
  • 230 posts
  • Location:your sister
  • Interests:see location

Posted 02 July 2005 - 09:28 PM

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

GreetingZ

#3 nightfox

nightfox

    NiGHTFoX - Hiding in the dark

  • Members
  • 680 posts

Posted 03 July 2005 - 01:39 AM

know how to do it for XML?

[N]F

#4 runefantasy

runefantasy

    Member - Active Contributor

  • Members
  • 90 posts

Posted 03 July 2005 - 04:27 AM

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

#5 hazeshow

hazeshow

    Premium Member

  • Members
  • 230 posts
  • Location:your sister
  • Interests:see location

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

#6 nightfox

nightfox

    NiGHTFoX - Hiding in the dark

  • Members
  • 680 posts

Posted 04 July 2005 - 03:24 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

<{POST_SNAPBACK}>

Ok, thanks! I'm going to go try this out now! :P

Thanks again!

[N]F

#7 jvizueta

jvizueta

    Newbie [ Level 2 ]

  • Members
  • 22 posts

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



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users