• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 279
  • Last Modified:

RSS feed consolidation in PHP

Hi

I want to do something like the code below (consolidate several RSS feeds on a single page) but that is in ASP and uses XSL. I do NOT want to learn XSL..Nor do I want some RSS to HTML solution based on an external server.

While I don't know much PHP I figured that there should be a class that would just grab a feed and let me iterate over its contents.

Suggestions, recommendations, simple test code?

thanks
0
Mutley2003
Asked:
Mutley2003
  • 2
1 Solution
 
Mutley2003Author Commented:
oops, forgot the ASP and XSL code
<html>
<!--  ======================================================
                  NEWS CONSOLIDATOR
                  
                  This is originally from
                  http://home.att.net/~codeLibrary/XML/rss.htm
      ======================================================
-->
<head>
<%
Sub getXML(sourceFile)
     dim styleFile
     dim source, style
     styleFile = Server.MapPath("news.xsl")

     set source = Server.CreateObject("Msxml2.DomDocument")
     source.async = false
     source.setProperty "ServerHTTPRequest", true
     source.load CStr(sourceFile)

     set style = Server.CreateObject("Msxml2.DomDocument")
     style.async = false
     style.load styleFile

     source.transformNodeToObject style, Response
     set source = nothing
     set style = nothing
End Sub
%>

</head>
<body>

<%
response.write("Hello World!")
%>
<hr />
<% getXML("http://radio.weblogs.com/0106235/rss.xml") %>
<hr />
<% getXML("http://radio.weblogs.com/0106735/rss.xml") %>
<hr />
<% getXML("http://radio.weblogs.com/0106985/rss.xml") %>


</body>
</html>

==================

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="iso-8859-1" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="*">
<table border="1" width="600" align="center">
<tr><td valign="top" align="center" class="title" bgcolor="silver" > 
<a>
<xsl:attribute name="href">
<xsl:value-of select="*[local-name()='channel']/*[local-name()='link']"/>
</xsl:attribute>
<xsl:attribute name="target">
<xsl:text>top</xsl:text>
</xsl:attribute>
<xsl:value-of select="*[local-name()='channel']/*[local-name()='title']" disable-output-escaping="yes"/>
</a>
<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
<xsl:value-of select="*[local-name()='channel']/*[local-name()='lastBuildDate']"/>
</td></tr><tr><td valign="top" bgcolor="ghostwhite" class="headlines" > 
<ul>
<xsl:for-each select="//*[local-name()='item']">
<li>
<a>
<xsl:attribute name="href">
<xsl:value-of select="*[local-name()='link']"/>
</xsl:attribute>
<xsl:attribute name="target">
<xsl:text>top</xsl:text>
</xsl:attribute>
<xsl:value-of select="*[local-name()='title']" disable-output-escaping="yes"/>
</a>
<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
<xsl:value-of select="*[local-name()='description']" disable-output-escaping="yes"/>
</li>
</xsl:for-each>
</ul>
</td></tr>
</table>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
0
 
RoonaanCommented:
There are many rssreader classes around.

Pear has got its XML_RSS class: http://pear.php.net/package/XML_RSS
Magpie also has one: http://magpierss.sourceforge.net/

And there are many more.

-r-
0
 
Mutley2003Author Commented:
thanks Roonaan .. that Magpie RssReader looks nice and easy .. just what I want

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now