Kinetic Pulse
  • Home
  • Services
  • Portfolio
  • Blog
  • Terms
  • Contact

Using ASP to display RSS feed with images from BBC news

August 3, 2009

I have been puzzling how to retrieve an RSS feed into a page of another webiste using classic ASP (in PHP I can heartily recommend the use of SimplePie)

I found some code which allowed me to get the list of items and links using XSLT to transform the retrieved XML – but had to do a bit more delving to find a way of dispalying the image thumbnails that you get in the more advanced RSS feeds.

Below is my solution:

This is the XSL stylesheet – call rssStyle.xslt:

<?xml version=”1.0″ encoding=”UTF-8″ ?>
<xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” xmlns:media=”http://search.yahoo.com/mrss“>
<xsl:output method=”html” omit-xml-declaration=”yes” />
<xsl:template match=”/”>
<xsl:for-each select=”rss/channel/item[position()&lt;=3]“>
<div class=”newsItem”>
<a>
<xsl:attribute name=”href”>
<xsl:value-of select=”link” />
</xsl:attribute>
<xsl:attribute name=”target”>_blank</xsl:attribute>
<img>
<xsl:attribute name=”src”>
<xsl:value-of select=”media:thumbnail/@url” disable-output-escaping=”yes” />
</xsl:attribute>
</img>

</a>

<h3 class=”highlight”><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>
</h3>

<p>
<xsl:value-of select=”description” disable-output-escaping=”yes” />
</p>

</div>

</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

This bits Darmed ar det ju inte sagt att en Casino http://s4gambling.com/se/ bonus vid registrering ar en dalig ide. in bold are respectively

1) The neamespace decalration to allow you to read teh media:thumbnail element

2) The test that allows you to show only the first 3 stories from feed

3) The code that actually shows the thumbnail image

Here is the code for the ASP page that shows the news feed – I”m using it as an include in another ASP page – but you can just get it to create the whole html page by uncommneting out the lines that write the header and footer of teh HTML page:

<%
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 “http://newsrss.bbc.co.uk/rss/newsplayer_uk_edition/business/rss.xml“
objXSL.load Server.MapPath(“rssStyle.xslt”)
“response.write “<html><head><title>RSS Feed Reader</title></head><body>”
response.write “<h2 id=””busNewsHead””>Latest Business News</h2>”
response.write “<p class=””small””>&copy; BBC News 2009</p>”
response.write “<div id=””businessNews””>”
response.write objXML.transformNode(objXSL)
response.write “</div>”
“response.write “</body></html>”
set objXML=nothing
set objXSL=nothing
%>

Share

Facebook Google+ Twitter Pinterest Email

Back to Blog

Testimonials

It’s been fab working with you – we love the site and certainly going to recommend you!
James DaviesThirty Eight Degrees North
Amazing and brilliant, Kinetic Pulse have lifted a dream to reality, Highly recommended and great if you are total novice, they know their stuff…Thanks again
Annie LindridgeSalt Yourself Out
Thanks so much for all your work on this, really appreciated. It’s come on in leaps and bounds since you took over.
Pete KewRedwood Strip Curtains
Thank you guys so much for all that you’ve done helping us to create a really awesome website!! We get such great feedback – everyone loves it & we couldn’t be prouder! Look forward to working with you again soon!
Wild Thyme PlantsWild Thyme Plants
Thank you for all of your hard work its looks fab and I am over the moon with it!
Amanda MercerAmanda Mercer Ceramics
Absolutely fantastically professional web developer – I would highly recommend!!! Thank you so much Kinetic Pulse!
Tania MarstonDoris Designs
I like it.  I like it a lot !!!

 You have interpreted what I wanted to achieve perfectly considering what you have to play with i.e not redoing the whole thing in the process.

Fiona Simmons-MooreSouth Gloucestershire Parents & Carers

Twitter

@HMRCcustomers Will do - thanks for the swift response

Last year from Kinetic Pulse's Twitter

@HMRCcustomers I've submitted Self Assessment repayment requests multiple times over the past 6 months (always waiting 4 weeks between) and never has anything happened. There seems to be no way of tracking or chasing them either. Now, of all times, this is important

Last year from Kinetic Pulse's Twitter

Apologies to all clients who have had website issues today. There was a major outage for our hosting company @cloudabove but, as always, they have been fantastically open and transparent about what's going on and are working hard to restore service.

About a year ago from Kinetic Pulse's Twitter

@thegrapesbath @bathdrummer Thanks - looking forward to opening night!

About 2 years ago from Kinetic Pulse's Twitter

woobox.com/tjkbms/k1orue

About 3 years ago from Kinetic Pulse's Twitter

Copyright 2021 Kinetic Pulse