人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

讀取符合RSS2.0規范的XML文檔

讀取符合RSS2.0規范的XML文檔

更新時間:2022-08-20 文章作者:未知 信息來源:網絡 閱讀次數:

想試著做一個簡單的讀取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


溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 建昌县| 历史| 博湖县| 濮阳县| 西吉县| 进贤县| 大名县| 冀州市| 茂名市| 多伦县| 威远县| 陇川县| 阿图什市| 仙游县| 上栗县| 玉门市| 镇沅| 岢岚县| 邢台县| 普定县| 连平县| 灵山县| 怀远县| 丘北县| 彭山县| 万州区| 井冈山市| 辉南县| 济源市| 张家界市| 连云港市| 华容县| 庐江县| 儋州市| 慈溪市| 盈江县| 巫山县| 黄平县| 清远市| 黄龙县| 绥芬河市|