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 38 online users.

    Latest tutorialsBuilding ASP.NET Web Forms to Use a MySQL Database
    A Guide to Upgrading Your XP Machine for Optimum Performance with Windows 7
    Retrieving Data from Microsoft SQL Server 2008 Using ASP.NET 3.5
    Creating an ASP.NET Dynamic Web Page Using MS SQL Server 2008 Database (GridView Display)
    Inserting Data into a Microsoft SQL 2008 Database in ASP.NET 3.5
    Using C#, ASP.NET, and ADO.NET To Develop A Multi-Tier App From Start To Finish
    URL Routing in ASP.NET 4.0
    Integrating Twitter Into An ASP.NET Website
    Creating Multiple Choice Exam Application Using ASP.NET MVC Framework
    Performance: Using dynamic code to copy property values of two objects
    A Look at the GridView's New Sorting Styles in ASP.NET 4.0
    .NET LINQ from Scratch
    The Kayak Framework: An easy way to speak HTTP with .NET
    How to Create a Custom Transform in UrlRewriter.net
    Applet and Servlet Communication
    ASP.NET Resources, Reviews

    ASP Resources, Reviews

    PHP, ASP, .NET, JSP Resources, Reviews

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