ASP RSS Parser, Feed Reader

This weekend I’ve been glued to my laptop searching the net for web-based RSS feed readers. The reason is that I wanted to write an asp RSS feed reader that would display the feed so that the content could be automatically scraped into an HTML email. So for folks who want to reserve a portion of their email newsletter for their Blog or Publication articles, it could be easily incorporated. Since JavaScript doesn’t actually display the content until the client loads and executes the script, the plethora of JavaScript RSS browsers weren’t useful. I needed a server-side RSS feed reader.

I began by writing my own parser in ASP using the MSXML object. I was able to parse about 75% of RSS feeds doing this, but some of the loose XML specifications on RSS feeds proved to be very difficult to program. You can see it in action here. You can pass the max number of items (ni), the number of characters cut off at the word (nc), as well as the URL. You can also see the actual feed with a debug variable here.

Many RSS feeds are really quite ‘dirty’ and require parsing the text in the XML file with string manipulation code (ugh!). Of course, we’re still in our RSS ‘youth’ on the net so I’m not surprised. Read more about RSS specifications here.

Finally, I came across a little gem. I found a free ASP class to download. It’s a little bit slow, but I haven’t found a feed that it was unable to read. I’ve got a static version here and a dynamic version here.

A couple notes on the script. I did need to clear out some HTML tags in the returned descriptions. I did that with a little cleanup function I found:

Function RemoveHTML(strText)
 Dim nPos1
 Dim nPos2
 nPos1 = InStr(strText, ">")
 Do While nPos1 > 0
 nPos2 = InStr(nPos1 + 1, strText, ">")
 If nPos2 > 0 Then
 strText = Left(strText, nPos1 - 1) & Mid(strText, nPos2 + 1)
 Else
 Exit Do
 End If
 nPos1 = InStr(strText, ">")
 Loop
 RemoveHTML = strText
 End Function

I also added another neat little bit of code: Sometimes, I might want to display more or less of a description. However, if I simply limit the number of characters, then I might cut off the description in the middle of the word. I don’t want to do that!

Function Cutoff(strText, intChars)
 dim intLength
 dim j
 intLength = len(strText)
 if intChars>intLength then
 for j =intChars to 0 step -1
 if mid(strText,j,1) = " " then exit for
 next
 if j>0 then
 strText = left(strText,j-1) & "..."
 else
 strText = strText
 end if
 end if
 Cutoff = strText
 End Function

(I had some problems with displaying my code correctly in this entry… let me know if you have problems with either of these functions!)

I’ve noticed quite a few more tools on the net as well. There is a
.NET version, many PHP versions, a ton of JavaScript versions.

To conclude, I hope that RSS specifications continue to be refined and the actual feeds comply with XML standards in all cases. Free applications like TypePad, WordPress, etc. need to refine their RSS functionality. Additional blogs like MySpace, Xanga, LiveJournal, etc. need to improve their RSS functionality. RSS IS powerful…Chris Baggott wrote a nice piece on Email vs. RSS. I think combining their functionality could increase the impact of both!

Download a Sponsored Marketing Whitepaper:
7 Top Tips for a Successful Employee Communications Strategy

7 Top Tips for a Successful Employee Communications Strategy

Make it easier to cut through and break down negative perceptions about the value of an IC strategy by using these steps. Download Now

This site uses Akismet to reduce spam. Learn how your comment data is processed.