logo
g Text Version
Auto
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Society & Culture
Sports
Travel & Leisure
TV & Movies

dailyclick
Bored? Games!
Postcards
Astrology
Take a Quiz
Rate My Photo

new
Women's Issues
Teaching LDS
Relationships
Action Movies
Twins


dailyclick
All times in EST

Full Schedule
g
g ASP Site
Editor Wanted
BellaOnline's ASP Editor

g

News Feed using RSS
Guest Author - Christopher Combs

News feed using RSS

Creating news articles is probably the one thing that really pushed RSS to its popularity. News in its basic definition is to inform and educate based on facts. Now that is not to say the news sometimes has opinions added to the mix. Either way, the electronic masses needed to get their articles out in a way for all to read and to get them when they were published. Enter RSS.

Using RSS to feed news is one of the most easiest ways to inform your readers of what is going on. As mentioned in my previous articles, you may want to build a front end interface, using ASP of course, to enter your news articles into your database. Having this front end will allow you to easily enter any new articles and not have to worry about getting into the database to enter them manually.

There are two parts to creating the RSS feed.

The header and the body. The header consist of some basic RSS code to format the feed correctly so that is can be read and processed by the readers. (You can get a free one from www.RSSReader.com) The body will include the information that is pulled from the database.

Here is how the header will always look:

<?xml version="1.0"
encoding="ISO-8859-1"?>

<% Response.Buffer = true
Response.ContentType = "text/xml"
Function ApplyXMLFormatting(strInput)
if len(strInput) > 0 then
strInput =
Replace(strInput,"&", "&")

strInput = Replace(strInput,"'", "'")
strInput = Replace(strInput,"""",
""")

strInput = Replace(strInput, ">",
">")

strInput = Replace(strInput,"<","<")
else
strInput = ""
end if
ApplyXMLFormatting = strInput
End Function
%>

Again, this will make sure that the RSS Reader can read the file correctly. The next piece is the body which will process the news records from the database. As long as you have the fields setup in the database, you should be good to go. (http://www.bellaonline.com/articles/art46418.asp)

The body of the file can look like this:

<rss version="2.0">
<channel>
<title>RSS Job Board -
ASP</title>

<link>http://asp.bellaonline.com</link>
<description>RSS Job Board for
ASP Developers</description>

<language>en-us</language>
<copyright>Copyright
2006</copyright>

<lastBuildDate><%=Now()%></lastBuildDate>
<ttl>20</ttl>
<image>
<url>http://www.bellaonline.com/images/bella.gif</url>
<title>ASP @ BellaOnline.com</title>
<link>http://asp.bellaonline.com</link>
</image>
<%
Dim objConn
Set objConn =
Server.CreateObject("ADODB.Connection")

Set objRS =
Server.CreateObject("ADODB.Recordset")

objConn.ConnectionString =

"Provider=sqloledb;Data Source=DBSERVER;Initial Catalog=ARTICLEDB;User Id=sa;Password=sqlpassword;"

objConn.CursorLocation = 3
objConn.Open
Dim objRS, strSQL, strDesc
strSQL = "SELECT * FROM RSSTable
WHERE (DateAdded <= '" & Now() & "') order by DateAdded DESC"

objRS.Open strSQL, objConn

Do While Not objRS.EOF
strDesc = "<b>Job Posted by " &
objRS("Owner") & " on " & _

objRS("DateAdded") & "
PST</b><br>" & _

objRS("Message").Value
%>

<item>
<title><%=ApplyXMLFormatting(objRS("ShortDesc").Value)%>


</title>
<link>http://asp.bellaonline.com</link>
<description><%=ApplyXMLFormatting(strDesc)%></description>
<guid><%=objRS("ID")%></guid>
<datePosted><%=objRS("DateAdded")%></datePosted>
<webMaster>asp@bellaonline.com
(Christopher Combs)</webMaster>

<author><%=objRS("Owner")%></author>
<comments>http://asp.bellaonline.com</comments>
<pubDate><%=objRS("DateAdded")%></pubDate></item><%
objRS.MoveNext
Loop
objRS.Close
objConn.Close
Set objRS = Nothing
Set objConn = Nothing
%></channel></rss>
Then save the file as an ASP or an RSS. (RSS making sure you have setup your server to accept RSS file requests as ASP – http://www.bellaonline.com/articles/art30642.asp)

If you have problems or questions regarding this or any other article, please let me know. asp@bellaonline.com

This site needs an editor - click to learn more!

RSS | Related Articles | Previous Features | Site Map


Content copyright © 2008 by Christopher Combs. All rights reserved.
This content was written by Christopher Combs. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.

Digg! g delicious Save to Del.icio.us

g


For FREE email updates, subscribe to the ASP Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor

g features
Best uses for RSS

RSS and its future.

Force Download Dialog box with ASP

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Driving Amount
Much more
Slightly more
Slightly less
Much less

g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2008 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor