日期:2009-03-07 浏览次数:20871 次
想试着做一个简单的读取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 StringobjXMLDoc.Load(RssUrl)
objItems = objXMLDoc.GetElementsByTagName("item")
If RssUrl = "" Then
RSSNews = "未找到信息源,您可刷新重试或联系管理员!"
Exit Function
End IfIf CStr(showNewsCount) = "" Or showNewsCount > 30 Then
showNewsCount = 10 '默认新闻显示数目
End IfIf showNewsCount = 0 Then
showNewsCount = objItems.Count
End IfIf objXMLDoc.HasChildNodes = True Then
i = 1
For Each objNode In objItemsIf objNode.HasChildNodes = True Then
objItems1 = objNode.ChildNodes
 免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。