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

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

new
Action Movies
Bible Basics
Houseplants
Romance Movies
Creativity
Family Travel
Southwest USA


dailyclick
All times in EST

Autism Spectrum Disorders: 4:00 PM

Full Schedule
g
g ASP Site

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
Add News+Feed+using+RSS to Twitter Add News+Feed+using+RSS to Facebook Add News+Feed+using+RSS to MySpace Add News+Feed+using+RSS to Del.icio.us Digg News+Feed+using+RSS Add News+Feed+using+RSS to Yahoo My Web Add News+Feed+using+RSS to Google Bookmarks Add News+Feed+using+RSS to Stumbleupon Add News+Feed+using+RSS to Reddit




RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


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


Content copyright © 2014 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 Lisa Shea for details.

g


g features
Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


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


BellaOnline Editor