Popular Articles | Latest Articles | Categories | RSS Feeds

Simple XMLRSS Parser Part-II

Published on 5/22/2008 by Dotnetindex
More articles in ASP



 Vote this tutorial:

This is second and extended version of simple XMLRSS parser. Simple XML/Parser is a XML parser designed for to parse most valid news and blog feeds. No database required to work with it. All you need is to include a subroutine in your code and call it. This version can also choose and display a limited number of feed.


Example Usage:
<%
rssParser "http://rss.news.yahoo.com/rss/topstories/", 3
%>

rssParser takes two parameters. Fİrst is URL of RSS feed and scond the number of how many headlines will be displayed.

rssParser subroutine:
<%
Sub rssParser(rssFile, num_headlines)

Dim objXML, objRoot, objItems, c
c = 0
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.Async = False
objXML.SetProperty "ServerHTTPRequest", True
objXML.ResolveExternals = True
objXML.ValidateOnParse = True
objXML.Load(rssFile)

If (objXML.parseError.errorCode = 0) Then
Set objRoot = objXML.documentElement
If IsObject(objRoot) = False Then
response.Write "

No Root Found in Rss File

"
End If

Set objItems = objRoot.getElementsByTagName("item")
If IsObject(objItems) = True Then
Dim objItem

 

i = 0

For Each objItem in objItems

i = i + 1

if i =< num_headlines then
strTitle = objItem.selectSingleNode("title").Text
On Error Resume Next
strDesc = objItem.selectSingleNode("description").Text
On Error Resume Next
strLink = objItem.selectSingleNode("link").Text
On Error Resume Next
strDate = objItem.selectSingleNode("pubDate").Text
On Error Resume Next


response.Write("

" & vbnewline)

response.Write(" " & vbnewline )
response.Write("
" & vbnewline )
response.Write("Title: " & strTitle & "
" & vbnewline )
response.Write("Link: "& strLink &"
" & vbnewline )
response.Write("Date : " & strDate & "
" & vbnewline )
response.Write( strDesc & "
" & vbnewline )
response.Write("

")
end if
Next
else
response.Write "

No Root Found in Rss File

"
exit sub
End If
Set objRoot = Nothing
Set objItems = Nothing
End If

Set objXML = Nothing
end sub

%>
Happy Coding

 

Comments:
no comments submitted


Only members can write comments.Please, login / register to write comment.

Latest Posts

    Active News Manager - news management system




    Welcome to Dotnetindex.com:Login  |  Register
    Free software:
    Giga RSS Reader
    IkonAdman
    QMailing list
    Active News
    Download Manager (PRO)
    Download Manager (Lite)

    Search Dotnetindex.com:


    Who's online

    • There 24 online users.

    Latest tutorialsAutocomplete Filter from the Old Futures Project Working in Dynamic Data 4
    Developing a Facebook Connect Application Using ASP.NET
    Conditional Row Highlighting in Dynamic Data
    UserControl as a DLL Made Easy
    Using GroupTemplate in ASP.NET ListView Control (Tiled Display)
    Creating Master-Detail GridView Using jQuery
    ASP.NET MVC 2.0 and AJAX Part 1
    Sorting Tabular Data in ASP.NET MVC
    Asynchronous Form in ASP.NET MVC 2
    Populating ASP.NET TreeView Control Recursively
    A look at SAP Crystal Reports for Visual Studio 2010
    Reporting in Threads
    Regular Expressions Make Pattern Matching and Data Extraction Easier
    Perform Database Administration Operations with SQL Server Management Objects
    SQL Server Compact 3.5 Beta 2 available for download
    ASP.NET Resources, Reviews

    ASP Resources, Reviews

    PHP, ASP, .NET, JSP Resources, Reviews

    Hotscripts.com Free Photoshop, Flash and 3DS MAX tutorials