选择显示字体大小

读取符合rss2.0规范的xml文档

想试着做一个简单的读取rss新闻的页面

虽然将.net中关于xml的几个类看了个遍

但还是不太懂

这是我写的一个读取xml文档的函数

直接在设计页面中调用就行

 

public function loadrss(byval rssurl as string, byval shownewscount as integer) as string

        try

            '读取xml文档
            dim objxmldoc as new system.xml.xmldocument()
            dim strnodes as string = ""
            dim objitems as system.xml.xmlnodelist
            dim objitems1 as system.xml.xmlnodelist
            dim objnode as system.xml.xmlnode
            dim objnode1 as system.xml.xmlnode
            dim i as integer
            dim newstitle as string
            dim newsurl as string
            dim newsdescription as string
            dim newspubdate as string
            dim newsauthor as string
            dim newscategory as string

            objxmldoc.load(rssurl)

            objitems = objxmldoc.getelementsbytagname("item")

            if rssurl = "" then
                rssnews = "未找到信息源,您可刷新重试或联系管理员!"
                exit function
            end if

            if cstr(shownewscount) = "" or shownewscount > 30 then
                shownewscount = 10        '默认新闻显示数目
            end if

            if shownewscount = 0 then
                shownewscount = objitems.count
            end if

            if objxmldoc.haschildnodes = true then
                i = 1
                for each objnode in objitems

                    if objnode.haschildnodes = true then
                        objitems1 = objnode.childnodes
                        for each objnode1 in objitems1

                            select case objnode1.name
                                case "title"
                                    newstitle = objnode1.innertext
                                case "link"
                                    newsurl = objnode1.innertext
                                case "description"
                                    newsdescription = objnode1.innertext
                                    if len(newsdescription) > 500 then
                                        newsdescription = left(newsdescription, 200)
                                    end if
                                    newsdescription = filterhtml(newsdescription)
                               case "category"
                                    newscategory = objnode1.innertext
                                case "author"
                                    newsauthor = objnode1.innertext
                                case "pubdate"
                                    newspubdate = objnode1.innertext
                            end select


                        next
                        strnodes += "<a href=viewnews.aspx?newstitle=" & server.urlencode(newstitle) & "&newsurl=" & server.urlencode(newsurl) & _
                                    "&newsdscrp=" & server.urlencode(newsdescription) & "&newscat=" & server.urlencode(newscategory) & _
                                    "&newsauthor=" & server.urlencode(newsauthor) & "&newsdate=" & server.urlencode(newspubdate) & _
                                    " target=_blank>" & newstitle & "</a><br>"
                    end if
                    i = i + 1
                    if i > shownewscount then exit for
                next
            end if

            loadrss = strnodes

        catch objerr as exception
            loadrss = "rss feed 源数据出错!"

        end try

    end function


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons