Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RSS Feed in ASP 1

Status
Not open for further replies.

cumap

IS-IT--Management
Jul 9, 2007
268
US
hello,

I'm interested in displaying RSS feeds in my website. I basically work with ASP and a little ASP.NET and hopefully someone can help me build the page in those languages, cause I found mostly tutorials out there in JS or PHP which I have no idea how to manipulate at all. By the way, is it true I need to have some kind of a RSS Reader software migrates into the page to read the feeds?

I did found tutorials in ASP like RSS2HTML.asp but an error: Access Denied from this line
Code:
xmlHttp.Send()
just through me off cause I'm totally not interested in begging those technicians to modify their server to accommodate my need (even if they can).

Thanks in advance!
 
Are you trying to read in feeds from other sites and display them in your page or producing your own feed that other people would consume? Sorry, it wasn't clear in your post above.

-T

Best MS KB Ever:
 
I'm sorry!!!

I do interested in doing both that is to display feeds from either mine or others that I like.

For ex: I'd like to have a input=text to except a link, then hit submit to display the feeds after that (basically the same with the one on Google).

This project is more like a study for me, but since I'm learning ASP, I'd like to do it in ASP instead of JS or PHP language. Do you think it is too much to learn on or I'm justing waisting time here? :)

Thank you!
 
Try this
Code:
Create a file called rss.asp
<%
function rss (url)
	dim styleFile, sourceFile,div
	dim source, style
	styleFile = Server.MapPath("rssXSLT.xsl")
	set source = Server.CreateObject("Msxml2.DOMDocument.3.0")
	source.async = false
	source.setProperty "ServerHTTPRequest", true
	source.load CStr(url)

	set style = Server.CreateObject("Msxml2.DOMDocument.3.0")
	style.async = false
	style.load styleFile
	temp = htmlize(source.transformNode(style))
	set source = nothing
	set style = nothing
	rss = temp
end function

Function htmlize(str)
	Dim s
	s = str
	s = Replace(s, "&amp;", "&")
	s = Replace(s, "&gt;", ">")
	s = Replace(s, "&lt;", "<")
	htmlize = s
End Function
%>
<html>
	<body>
		<form action="rsstest.asp" method="get">
			<p>RSS Feed URL <input name="url" type="text"/> <input type="submit" name="submit" value="Read" /><p>
		</form>
		<hr />
	</body>
</html>
<%
if request.querystring("url") <> "" then response.write(rss(request("url")))
%>

then

Code:
create a file called rssXSLT.xsl

<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
	<xsl:output method="html" />
	<xsl:template match="rss/channel">
	<xsl:apply-templates select="title" />
		<xsl:for-each select="//*[local-name()='item']">
			<xsl:if test="position() &lt; 6">
				<div style="padding-bottom:2px;"><a href='{link}' target='_blank'><xsl:value-of select="title" /> - <xsl:value-of select='pubDate' /></a><br /><xsl:value-of select="description" /> </div>
			</xsl:if>
		</xsl:for-each>
	</xsl:template>
	<xsl:template match="title">
		<div style="text-decoration:underline;padding-bottom:4px;font-weight:bold;font-size:110%;"><xsl:value-of select="text()" /></div>
	</xsl:template>
</xsl:stylesheet>


}...the bane of my life!
 
To guitardave78,

It seems to me that your example is missing a page namely "rsstest.asp", isn't it?
 
Nevermind, I believe you forgot to synchronize the file name between css.asp and rsstest.asp, but I got it now and it seems to work just fine as I tested.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top