Forum Moderators: mack

Message Too Old, No Replies

Inserting RSS feed

inserting an rss feed

         

lindsey_h

9:52 am on Jul 7, 2006 (gmt 0)

10+ Year Member



Hello

Please can anyone tell me how to put an RSS feed into one's site? I have the following code in my html page:

<%
Dim mm_xsl: Set mm_xsl = new MM_XSLTransform
' mm_xsl.setXML "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/business/e-commerce/rss.xml"
mm_xsl.setXML "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/business/rss.xml"
mm_xsl.setXSL "bbcEcommerceNewsfeed.xsl"
mm_xsl.addParameter "ItemsPerPage", "4"
Response.write mm_xsl.Transform()
%>

Yes, I do have the file in the root of my site called bbcEcommerceNewsfeed.xsl! Here it is:

<?xml version="1.0" encoding="iso-8859-1"?><!-- DWXMLSource="http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/business/e-commerce/rss.xml" -->
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp "&#160;">
<!ENTITY copy "&#169;">
<!ENTITY reg "&#174;">
<!ENTITY trade "&#8482;">
<!ENTITY mdash "&#8212;">
<!ENTITY ldquo "&#8220;">
<!ENTITY rdquo "&#8221;">
<!ENTITY pound "&#163;">
<!ENTITY yen "&#165;">
<!ENTITY euro "&#8364;">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1"/>
<xsl:param name="ItemsPerPage" select="4" />
<xsl:template match="/">
<xsl:for-each select="rss/channel/item[position() &lt;= $ItemsPerPage]">
<h2><a href="{link}" target="_blank"><xsl:value-of select="title"/></a></h2>
<p><xsl:value-of select="description" disable-output-escaping="yes"/></p>
</xsl:for-each>

</xsl:template>
</xsl:stylesheet>

Have uploaded all, but nothing shows on my html page at all.

Have I missed something vital out - Really Simple Syndication! Not that simple perhaps?

Thanks.

Lindsey

coopster

12:48 pm on Jul 7, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Hi lindsey_h and welcome to WebmasterWorld!

There is a forum here at WebmasterWorld called RSS and Related Technologies [webmasterworld.com] that I think you are going to find quite helpful. In the RSS and Related Technologies Forum Library [webmasterworld.com] there is a Short guide to include RSS on your website [webmasterworld.com].

Jim Catanich

2:36 am on Jul 27, 2006 (gmt 0)

10+ Year Member



Classic ASP RSS News Feed

First you create a simple subroutine called GetRssFeed and you pass it the URL of the feed you want (strFeedURL).

<%
Sub GetRssFeed (strFeedUrl)
response.ContentType="text/html"
dim objXML, objXSL
set objXML=server.CreateObject("MSXML2.DOMDocument")
set objXSL=server.CreateObject("MSXML2.DOMDocument")
objXML.async=False
objXSL.async=False
objXML.setProperty "ServerHTTPRequest",true
objXML.load strFeedUrl
objXSL.load Server.MapPath("rssStyle.xslt")
response.write objXML.transformNode(objXSL)
set objXML=nothing
set objXSL=nothing
end sub
%>

Then on your web page you place the follow code

<table>
<tr>
<td>
<h2>What's New At Google</h2>
<%GetRssFeed "http://news.com.com/2063-10812_3-0.xml"%><br><br>

<h2>New York Times Business Section</h2>
<%GetRssFeed "http://www.nytimes.com/services/xml/rss/nyt/WorldBusiness.xml"%><br><br>

<h2>SEO Chat</h2>
<%GetRssFeed "http://feeds.feedburner.com/#*$!/articles/"%><br><br>
<h2>Technology News</h2>

<%GetRssFeed "http://www.nytimes.com/services/xml/rss/nyt/Technology.xml"%><br><br>
</td>
</tr>
</table>

And finally you create a XSLT file and place it at the SAME LEVEL as the web page. Name it "rssStyle.xslt" as in line 14 above.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" omit-xml-declaration="yes" />

<xsl:template match="/rss/channel">
<b><xsl:value-of select="title" disable-output-escaping="yes" /></b>
<xsl:for-each select="item">
<li>
<a>
<xsl:attribute name="href">
<xsl:value-of select="link" />
</xsl:attribute>
<xsl:attribute name="target">_blank</xsl:attribute>
<xsl:value-of select="title" disable-output-escaping="yes" />
</a>
(<xsl:value-of select="pubDate" />)
</li>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

A working demo of this is at [catanich.com...] Lower right of home page. Email me if it doesn't work and I will email you back what I have that is working.

That is it. Happy Feeding

Jim Catanich