Here I am..had to go into my archives because I don't work with classic asp anymore...(try asp.net Pilot...it will blow you away)
The rss-writer (you can publish rss with this code. Wrote this myself):
NOTE: change the session.lcid=1043 into your own country code...
Code:
<%@ Language=VBScript %>
<%option explicit%>
<%
session.lcid=1043
Response.ContentType = "text/xml"
DIM adoCon, adoRec
Function ApplyXMLFormatting(strInput)
strInput = Replace(strInput,"&", "&")
strInput = Replace(strInput,"'", "'")
strInput = Replace(strInput,"""", """)
strInput = Replace(strInput, ">", ">")
strInput = Replace(strInput,"<","<")
ApplyXMLFormatting = strInput
End Function
Function StartConnection()
Dim strCon
strCon = "<your connection>"
Set adoCon = Server.CreateObject("Adodb.COnnection")
adoCon.Open strCon
Set adoRec = Server.CreateObject( "ADODB.RecordSet")
adoRec.ActiveConnection = adoCon
End Function
Function EndConnection()
Set adoRec=Nothing
adoCon.close
Set adoCon=Nothing
End Function
'GetRows Method
Function GetRecords(strSQL)
' getrows
startConnection()
adoRec.open strSQL, adoCon
If Not (adoRec.BOF AND adoRec.EOF) Then
GetRecords = adoRec.GetRows()
End If
adoRec.Close
EndConnection()
End Function
%>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="2.0">
<channel>
<title>Mijn Rss Feed creator</title>
<link>http://www.mylink.nl</link>
<description>Mijn omschrijving</description>
<language>nl</language>
<copyright>Copyright 2004 Martin Jansen. All Rights Reserved.</copyright>
<lastBuildDate><%=Now()%></lastBuildDate>
<%
'Create rows
Dim intTeller, aArtikel, strSQL
strSQL = "SELECT nId, dDate, cTitle, cDescription FROM myArticles ORDER BY dDate DESC"
aArtikel = getRecords(strSQL)
If isArray(aArtikel) then
For intTeller = 0 to Ubound(aArtikel,2)
response.write " <item>" & VbCrLf
response.write " <pubDate>" & aArtikel(1,intTeller) & "</pubDate>" & vbCrLf
response.write " <title>" & ApplyXMLFormatting(aArtikel(2,intTeller)) & "</title>" & VbCrLf
response.write " <link>http://www.mylink.nl/artikelen.asp?ID=" & aArtikel(0,intTeller) & "</link>" & VbCrLf
response.write " <description>" & ApplyXMLFormatting(aArtikel(3,intTeller)) & "</description>" & VbCrLf
response.write " </item>" & VbCrLf
Next
End If
%>
</channel>
</rss>
And this is a reader method (grabbed this from the net):
Code:
<%
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://thefeed.com
objXSL.load Server.MapPath("rssStyle.xslt")
response.write "<html><head><title>RSS Feed Reader</title></head><body>"
response.write objXML.transformNode(objXSL)
response.write "</body></html>"
set objXML=nothing
set objXSL=nothing
%>
And this is the XSLT file (named rssStyle.xslt)
Code:
<?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>
For customizing the Feed layout simply change the XSLT file!
Martin
Bookmarks