用vb.net写一个简易的RSS阅读器-阿里云开发者社区

开发者社区> 云计算> 正文
登录阅读全文

用vb.net写一个简易的RSS阅读器

简介: 先发一个做出来的效果图哈哈!怎么样?对了DUDU,我这个还解决了看天下那个阅读器不能正常显示相对路径的图片的问题哟!现在不管相对的还是绝对的路径的图片都能正常显示哈!下面是源代码,没有太多注释,因为都比较简单嘛! Imports System.
先发一个做出来的效果图
rssreader.JPG
哈哈!怎么样?对了DUDU,我这个还解决了看天下那个阅读器不能正常显示相对路径的图片的问题哟!
现在不管相对的还是绝对的路径的图片都能正常显示哈!

下面是源代码,没有太多注释,因为都比较简单嘛!
img_a6339ee3e57d1d52bc7d02b338e15a60.gifImports System.Xml
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
Imports System.Threading
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_405b18b4b6584ae338e0f6ecaf736533.gifimg_1c53668bcee393edac0d7b3b3daff1ae.gif
Public Class Form1Class Form1
img_33d02437d135341f0800e3d415312ae8.gif    
Inherits System.Windows.Forms.Form
img_33d02437d135341f0800e3d415312ae8.gif#Region 
" Windows 窗体设计器生成的代码 "
img_33d02437d135341f0800e3d415312ae8.gif

img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
    Public Sub New()Sub New()
img_33d02437d135341f0800e3d415312ae8.gif        
MyBase.New()
img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif        
'该调用是 Windows 窗体设计器所必需的。
img_33d02437d135341f0800e3d415312ae8.gif
        InitializeComponent()
img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif        
'在 InitializeComponent() 调用之后添加任何初始化
img_33d02437d135341f0800e3d415312ae8.gif

img_105a1e124122b2abcee4ea8e9f5108f3.gif    
End Sub

img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif    
'窗体重写 dispose 以清理组件列表。
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
    Protected Overloads Overrides Sub Dispose()Sub Dispose(ByVal disposing As Boolean)
img_33d02437d135341f0800e3d415312ae8.gif        
If disposing Then
img_33d02437d135341f0800e3d415312ae8.gif            
If Not (components Is NothingThen
img_33d02437d135341f0800e3d415312ae8.gif                components.Dispose()
img_33d02437d135341f0800e3d415312ae8.gif            
End If
img_33d02437d135341f0800e3d415312ae8.gif        
End If
img_33d02437d135341f0800e3d415312ae8.gif        
MyBase.Dispose(disposing)
img_105a1e124122b2abcee4ea8e9f5108f3.gif    
End Sub

img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif    
'Windows 窗体设计器所必需的
img_33d02437d135341f0800e3d415312ae8.gif
    Private components As System.ComponentModel.IContainer
img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif    
'注意: 以下过程是 Windows 窗体设计器所必需的
img_33d02437d135341f0800e3d415312ae8.gif
    '可以使用 Windows 窗体设计器修改此过程。
img_33d02437d135341f0800e3d415312ae8.gif
    '不要使用代码编辑器修改它。
img_33d02437d135341f0800e3d415312ae8.gif
    Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
img_33d02437d135341f0800e3d415312ae8.gif    
Friend WithEvents Button1 As System.Windows.Forms.Button
img_33d02437d135341f0800e3d415312ae8.gif    
Friend WithEvents AxWebBrowser1 As AxSHDocVw.AxWebBrowser
img_33d02437d135341f0800e3d415312ae8.gif    
Friend WithEvents Label1 As System.Windows.Forms.Label
img_33d02437d135341f0800e3d415312ae8.gif    
Friend WithEvents Label2 As System.Windows.Forms.Label
img_33d02437d135341f0800e3d415312ae8.gif    
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
img_33d02437d135341f0800e3d415312ae8.gif    
Friend WithEvents StatusBar1 As System.Windows.Forms.StatusBar
img_33d02437d135341f0800e3d415312ae8.gif    
Friend WithEvents Label4 As System.Windows.Forms.Label
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()Sub InitializeComponent()
img_33d02437d135341f0800e3d415312ae8.gif        
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
img_33d02437d135341f0800e3d415312ae8.gif        Me.ListBox1 
= New System.Windows.Forms.ListBox
img_33d02437d135341f0800e3d415312ae8.gif        Me.Button1 
= New System.Windows.Forms.Button
img_33d02437d135341f0800e3d415312ae8.gif        Me.AxWebBrowser1 
= New AxSHDocVw.AxWebBrowser
img_33d02437d135341f0800e3d415312ae8.gif        Me.Label1 
= New System.Windows.Forms.Label
img_33d02437d135341f0800e3d415312ae8.gif        Me.Label2 
= New System.Windows.Forms.Label
img_33d02437d135341f0800e3d415312ae8.gif        Me.TextBox1 
= New System.Windows.Forms.TextBox
img_33d02437d135341f0800e3d415312ae8.gif        Me.StatusBar1 
= New System.Windows.Forms.StatusBar
img_33d02437d135341f0800e3d415312ae8.gif        Me.Label4 
= New System.Windows.Forms.Label
img_33d02437d135341f0800e3d415312ae8.gif        
CType(Me.AxWebBrowser1, System.ComponentModel.ISupportInitialize).BeginInit()
img_33d02437d135341f0800e3d415312ae8.gif        Me.SuspendLayout()
img_33d02437d135341f0800e3d415312ae8.gif        
'
img_33d02437d135341f0800e3d415312ae8.gif
        'ListBox1
img_33d02437d135341f0800e3d415312ae8.gif
        '
img_33d02437d135341f0800e3d415312ae8.gif
        Me.ListBox1.ItemHeight = 12
img_33d02437d135341f0800e3d415312ae8.gif        Me.ListBox1.Location 
= New System.Drawing.Point(072)
img_33d02437d135341f0800e3d415312ae8.gif        Me.ListBox1.Name 
= "ListBox1"
img_33d02437d135341f0800e3d415312ae8.gif
        Me.ListBox1.Size = New System.Drawing.Size(872124)
img_33d02437d135341f0800e3d415312ae8.gif        Me.ListBox1.TabIndex 
= 0
img_33d02437d135341f0800e3d415312ae8.gif        
'
img_33d02437d135341f0800e3d415312ae8.gif
        'Button1
img_33d02437d135341f0800e3d415312ae8.gif
        '
img_33d02437d135341f0800e3d415312ae8.gif
        Me.Button1.Location = New System.Drawing.Point(7600)
img_33d02437d135341f0800e3d415312ae8.gif        Me.Button1.Name 
= "Button1"
img_33d02437d135341f0800e3d415312ae8.gif
        Me.Button1.Size = New System.Drawing.Size(11272)
img_33d02437d135341f0800e3d415312ae8.gif        Me.Button1.TabIndex 
= 1
img_33d02437d135341f0800e3d415312ae8.gif        Me.Button1.Text 
= "读取"
img_33d02437d135341f0800e3d415312ae8.gif
        '
img_33d02437d135341f0800e3d415312ae8.gif
        'AxWebBrowser1
img_33d02437d135341f0800e3d415312ae8.gif
        '
img_33d02437d135341f0800e3d415312ae8.gif
        Me.AxWebBrowser1.Enabled = True
img_33d02437d135341f0800e3d415312ae8.gif        Me.AxWebBrowser1.Location 
= New System.Drawing.Point(0208)
img_33d02437d135341f0800e3d415312ae8.gif        Me.AxWebBrowser1.OcxState 
= CType(resources.GetObject("AxWebBrowser1.OcxState"), System.Windows.Forms.AxHost.State)
img_33d02437d135341f0800e3d415312ae8.gif        Me.AxWebBrowser1.Size 
= New System.Drawing.Size(872512)
img_33d02437d135341f0800e3d415312ae8.gif        Me.AxWebBrowser1.TabIndex 
= 2
img_33d02437d135341f0800e3d415312ae8.gif        
'
img_33d02437d135341f0800e3d415312ae8.gif
        'Label1
img_33d02437d135341f0800e3d415312ae8.gif
        '
img_33d02437d135341f0800e3d415312ae8.gif
        Me.Label1.Location = New System.Drawing.Point(2432)
img_33d02437d135341f0800e3d415312ae8.gif        Me.Label1.Name 
= "Label1"
img_33d02437d135341f0800e3d415312ae8.gif
        Me.Label1.Size = New System.Drawing.Size(72816)
img_33d02437d135341f0800e3d415312ae8.gif        Me.Label1.TabIndex 
= 3
img_33d02437d135341f0800e3d415312ae8.gif        Me.Label1.Text 
= "网站:"
img_33d02437d135341f0800e3d415312ae8.gif
        '
img_33d02437d135341f0800e3d415312ae8.gif
        'Label2
img_33d02437d135341f0800e3d415312ae8.gif
        '
img_33d02437d135341f0800e3d415312ae8.gif
        Me.Label2.Location = New System.Drawing.Point(2448)
img_33d02437d135341f0800e3d415312ae8.gif        Me.Label2.Name 
= "Label2"
img_33d02437d135341f0800e3d415312ae8.gif
        Me.Label2.Size = New System.Drawing.Size(72816)
img_33d02437d135341f0800e3d415312ae8.gif        Me.Label2.TabIndex 
= 4
img_33d02437d135341f0800e3d415312ae8.gif        Me.Label2.Text 
= "描述:"
img_33d02437d135341f0800e3d415312ae8.gif
        '
img_33d02437d135341f0800e3d415312ae8.gif
        'TextBox1
img_33d02437d135341f0800e3d415312ae8.gif
        '
img_33d02437d135341f0800e3d415312ae8.gif
        Me.TextBox1.Location = New System.Drawing.Point(880)
img_33d02437d135341f0800e3d415312ae8.gif        Me.TextBox1.Name 
= "TextBox1"
img_33d02437d135341f0800e3d415312ae8.gif
        Me.TextBox1.Size = New System.Drawing.Size(66421)
img_33d02437d135341f0800e3d415312ae8.gif        Me.TextBox1.TabIndex 
= 6
img_33d02437d135341f0800e3d415312ae8.gif        Me.TextBox1.Text 
= "http://www.cnblogs.com/aowind/Rss.aspx"
img_33d02437d135341f0800e3d415312ae8.gif
        '
img_33d02437d135341f0800e3d415312ae8.gif
        'StatusBar1
img_33d02437d135341f0800e3d415312ae8.gif
        '
img_33d02437d135341f0800e3d415312ae8.gif
        Me.StatusBar1.Location = New System.Drawing.Point(0725)
img_33d02437d135341f0800e3d415312ae8.gif        Me.StatusBar1.Name 
= "StatusBar1"
img_33d02437d135341f0800e3d415312ae8.gif
        Me.StatusBar1.Size = New System.Drawing.Size(87224)
img_33d02437d135341f0800e3d415312ae8.gif        Me.StatusBar1.TabIndex 
= 7
img_33d02437d135341f0800e3d415312ae8.gif        Me.StatusBar1.Text 
= "StatusBar1"
img_33d02437d135341f0800e3d415312ae8.gif
        '
img_33d02437d135341f0800e3d415312ae8.gif
        'Label4
img_33d02437d135341f0800e3d415312ae8.gif
        '
img_33d02437d135341f0800e3d415312ae8.gif
        Me.Label4.Location = New System.Drawing.Point(168)
img_33d02437d135341f0800e3d415312ae8.gif        Me.Label4.Name 
= "Label4"
img_33d02437d135341f0800e3d415312ae8.gif
        Me.Label4.Size = New System.Drawing.Size(6416)
img_33d02437d135341f0800e3d415312ae8.gif        Me.Label4.TabIndex 
= 8
img_33d02437d135341f0800e3d415312ae8.gif        Me.Label4.Text 
= "RSS地址:"
img_33d02437d135341f0800e3d415312ae8.gif
        '
img_33d02437d135341f0800e3d415312ae8.gif
        'Form1
img_33d02437d135341f0800e3d415312ae8.gif
        '
img_33d02437d135341f0800e3d415312ae8.gif
        Me.AutoScaleBaseSize = New System.Drawing.Size(614)
img_33d02437d135341f0800e3d415312ae8.gif        Me.ClientSize 
= New System.Drawing.Size(872749)
img_33d02437d135341f0800e3d415312ae8.gif        Me.Controls.Add(Me.Label4)
img_33d02437d135341f0800e3d415312ae8.gif        Me.Controls.Add(Me.StatusBar1)
img_33d02437d135341f0800e3d415312ae8.gif        Me.Controls.Add(Me.TextBox1)
img_33d02437d135341f0800e3d415312ae8.gif        Me.Controls.Add(Me.Label2)
img_33d02437d135341f0800e3d415312ae8.gif        Me.Controls.Add(Me.Label1)
img_33d02437d135341f0800e3d415312ae8.gif        Me.Controls.Add(Me.AxWebBrowser1)
img_33d02437d135341f0800e3d415312ae8.gif        Me.Controls.Add(Me.Button1)
img_33d02437d135341f0800e3d415312ae8.gif        Me.Controls.Add(Me.ListBox1)
img_33d02437d135341f0800e3d415312ae8.gif        Me.Name 
= "Form1"
img_33d02437d135341f0800e3d415312ae8.gif
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
img_33d02437d135341f0800e3d415312ae8.gif        Me.Text 
= "简易RSS阅读器"
img_33d02437d135341f0800e3d415312ae8.gif
        CType(Me.AxWebBrowser1, System.ComponentModel.ISupportInitialize).EndInit()
img_33d02437d135341f0800e3d415312ae8.gif        Me.ResumeLayout(
False)
img_33d02437d135341f0800e3d415312ae8.gif
img_105a1e124122b2abcee4ea8e9f5108f3.gif    
End Sub

img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif#
End Region
img_33d02437d135341f0800e3d415312ae8.gif    
Private thread As thread '定义一个线程
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
    Private Sub loadrss()Sub loadrss() '读取RSS文件并取出内容标题的过程
img_33d02437d135341f0800e3d415312ae8.gif
        StatusBar1.Text = "正在读取" & TextBox1.Text & "并效验img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif"
img_33d02437d135341f0800e3d415312ae8.gif
        Me.loadxmltocache(TextBox1.Text)
img_33d02437d135341f0800e3d415312ae8.gif        StatusBar1.Text 
= "正在读取相关网站信息img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif"
img_33d02437d135341f0800e3d415312ae8.gif
        Me.loadtitle()
img_33d02437d135341f0800e3d415312ae8.gif        StatusBar1.Text 
= "正在读取相RSS内容项img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif"
img_33d02437d135341f0800e3d415312ae8.gif
        Me.loaditem()
img_33d02437d135341f0800e3d415312ae8.gif        StatusBar1.Text 
= "完成"
img_105a1e124122b2abcee4ea8e9f5108f3.gif
    End Sub

img_33d02437d135341f0800e3d415312ae8.gif
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
Private Sub Button1_Click()Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button1.Click
img_33d02437d135341f0800e3d415312ae8.gif        
Try
img_33d02437d135341f0800e3d415312ae8.gif            thread 
= New Thread(AddressOf loadrss)
img_33d02437d135341f0800e3d415312ae8.gif            thread.Start()
img_33d02437d135341f0800e3d415312ae8.gif        
Catch ex As Exception
img_33d02437d135341f0800e3d415312ae8.gif            
MsgBox(ex.ToString)
img_33d02437d135341f0800e3d415312ae8.gif        
End Try
img_105a1e124122b2abcee4ea8e9f5108f3.gif    
End Sub

img_33d02437d135341f0800e3d415312ae8.gif
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
Private Sub Form1_Load()Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load
img_33d02437d135341f0800e3d415312ae8.gif        AxWebBrowser1.Width 
= Me.Width
img_33d02437d135341f0800e3d415312ae8.gif        StatusBar1.Text 
= "就绪"
img_105a1e124122b2abcee4ea8e9f5108f3.gif
    End Sub

img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
Private Sub loadxmltocache()Sub loadxmltocache(ByVal URL As String)
img_33d02437d135341f0800e3d415312ae8.gif        
'读取RSS文件并存放在本地以供操作
img_33d02437d135341f0800e3d415312ae8.gif
        Dim xmldocument As New XmlDocument
img_33d02437d135341f0800e3d415312ae8.gif        xmldocument.Load(URL)
img_33d02437d135341f0800e3d415312ae8.gif        xmldocument.Save(Application.StartupPath 
& "~doc.xml")
img_33d02437d135341f0800e3d415312ae8.gif
img_105a1e124122b2abcee4ea8e9f5108f3.gif    
End Sub

img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
Private Sub loadtitle()Sub loadtitle()
img_33d02437d135341f0800e3d415312ae8.gif        
'从本地文件中进行操作,读取RSS中有关网站的信息
img_33d02437d135341f0800e3d415312ae8.gif
        Dim xmlDocument As New XmlDocument
img_33d02437d135341f0800e3d415312ae8.gif        xmlDocument.Load(Application.StartupPath 
& "~doc.xml")
img_33d02437d135341f0800e3d415312ae8.gif        
Dim mynodelist As XmlNodeList
img_33d02437d135341f0800e3d415312ae8.gif        mynodelist 
= xmlDocument.SelectNodes("/rss/channel")
img_33d02437d135341f0800e3d415312ae8.gif        Label1.Text 
= "网站:" & Trim(mynodelist(0).Item("title").InnerText())
img_33d02437d135341f0800e3d415312ae8.gif        Label2.Text 
= "描述:" & Trim(mynodelist(0).Item("description").InnerText())
img_105a1e124122b2abcee4ea8e9f5108f3.gif    
End Sub

img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
Private Sub loaditem()Sub loaditem()
img_33d02437d135341f0800e3d415312ae8.gif        
'从本地文件中进行操作,读取RSS中内容的标题及作者
img_33d02437d135341f0800e3d415312ae8.gif
        Dim xmlDocument As New XmlDocument
img_33d02437d135341f0800e3d415312ae8.gif        xmlDocument.Load(Application.StartupPath 
& "~doc.xml")
img_33d02437d135341f0800e3d415312ae8.gif        
Dim mynodelist As XmlNodeList
img_33d02437d135341f0800e3d415312ae8.gif        mynodelist 
= xmlDocument.SelectNodes("/rss/channel/item")
img_33d02437d135341f0800e3d415312ae8.gif        ListBox1.Items.Clear()
img_33d02437d135341f0800e3d415312ae8.gif        
Dim i As Integer
img_33d02437d135341f0800e3d415312ae8.gif        
For i = 0 To mynodelist.Count - 1
img_33d02437d135341f0800e3d415312ae8.gif            ListBox1.Items.Add(
"[" & Trim(mynodelist(i).Item("dc:creator").InnerText()) & "]" & Trim(mynodelist(i).Item("title").InnerText()))
img_33d02437d135341f0800e3d415312ae8.gif        
Next
img_105a1e124122b2abcee4ea8e9f5108f3.gif    
End Sub

img_33d02437d135341f0800e3d415312ae8.gif
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
Private Sub ListBox1_SelectedIndexChanged()Sub ListBox1_SelectedIndexChanged(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
img_33d02437d135341f0800e3d415312ae8.gif        thread 
= New Thread(AddressOf loadhtml)
img_33d02437d135341f0800e3d415312ae8.gif        thread.Start()
img_105a1e124122b2abcee4ea8e9f5108f3.gif    
End Sub

img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
Private Sub loadhtml()Sub loadhtml()
img_33d02437d135341f0800e3d415312ae8.gif        
'读取RSS中对应文件的内容并存到临时文件后显示
img_33d02437d135341f0800e3d415312ae8.gif
        Dim xmlDocument As New XmlDocument
img_33d02437d135341f0800e3d415312ae8.gif        xmlDocument.Load(Application.StartupPath 
& "~doc.xml")
img_33d02437d135341f0800e3d415312ae8.gif        
Dim mynodelist As XmlNodeList
img_33d02437d135341f0800e3d415312ae8.gif        mynodelist 
= xmlDocument.SelectNodes("/rss/channel/item")
img_33d02437d135341f0800e3d415312ae8.gif        
Dim i As Integer
img_33d02437d135341f0800e3d415312ae8.gif        
Dim j As Boolean
img_33d02437d135341f0800e3d415312ae8.gif        
Dim content As String
img_33d02437d135341f0800e3d415312ae8.gif        StatusBar1.Text 
= "正在读取文章内容img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif"
img_33d02437d135341f0800e3d415312ae8.gif
        For i = 0 To mynodelist.Count - 1
img_33d02437d135341f0800e3d415312ae8.gif            
If ListBox1.SelectedItem = "[" & Trim(mynodelist(i).Item("dc:creator").InnerText()) & "]" & Trim(mynodelist(i).Item("title").InnerText()) Then
img_33d02437d135341f0800e3d415312ae8.gif                content 
= content & "<html><head><meta http-equiv='content-type' content='text/html;charset=UTF-8'></head><body>"
img_33d02437d135341f0800e3d415312ae8.gif
                content = content & "<table width='100%' height='80' bgcolor='#eeeeee'><tr><td><b>标题:</b><a href='"
img_33d02437d135341f0800e3d415312ae8.gif
                content = content & Trim(mynodelist(i).Item("link").InnerText())
img_33d02437d135341f0800e3d415312ae8.gif                content 
= content & "' target='_blank'>"
img_33d02437d135341f0800e3d415312ae8.gif
                content = content & Trim(mynodelist(i).Item("title").InnerText())
img_33d02437d135341f0800e3d415312ae8.gif                content 
= content & "</a><br><b>作者:</b>"
img_33d02437d135341f0800e3d415312ae8.gif
                content = content & Trim(mynodelist(i).Item("dc:creator").InnerText())
img_33d02437d135341f0800e3d415312ae8.gif                content 
= content & "</tb></tr></table>"
img_33d02437d135341f0800e3d415312ae8.gif
                content = content & formatHtml(mynodelist(i).Item("description").InnerText())
img_33d02437d135341f0800e3d415312ae8.gif                content 
= content & "</body></html>"
img_33d02437d135341f0800e3d415312ae8.gif
                j = SaveTextFile(Application.StartupPath & "~temp.html", content)
img_33d02437d135341f0800e3d415312ae8.gif                AxWebBrowser1.Navigate(Application.StartupPath 
& "~temp.html")
img_33d02437d135341f0800e3d415312ae8.gif                
Exit For
img_33d02437d135341f0800e3d415312ae8.gif            
End If
img_33d02437d135341f0800e3d415312ae8.gif        
Next
img_33d02437d135341f0800e3d415312ae8.gif        StatusBar1.Text 
= "完成"
img_105a1e124122b2abcee4ea8e9f5108f3.gif
    End Sub

img_33d02437d135341f0800e3d415312ae8.gif    
'写文件的过程
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
    Function SaveTextFile()Function SaveTextFile(ByVal FilePath As StringByVal FileContent As StringAs Boolean
img_33d02437d135341f0800e3d415312ae8.gif        
Dim sw As System.IO.StreamWriter
img_33d02437d135341f0800e3d415312ae8.gif        
Try
img_33d02437d135341f0800e3d415312ae8.gif            sw 
= New System.IO.StreamWriter(FilePath, False)
img_33d02437d135341f0800e3d415312ae8.gif            sw.
Write(FileContent)
img_33d02437d135341f0800e3d415312ae8.gif            
Return True
img_33d02437d135341f0800e3d415312ae8.gif        
Catch e As Exception
img_33d02437d135341f0800e3d415312ae8.gif            
Return False
img_33d02437d135341f0800e3d415312ae8.gif        
Finally
img_33d02437d135341f0800e3d415312ae8.gif            
If Not sw Is Nothing Then sw.Close()
img_33d02437d135341f0800e3d415312ae8.gif        
End Try
img_105a1e124122b2abcee4ea8e9f5108f3.gif    
End Function

img_33d02437d135341f0800e3d415312ae8.gif    
'从地址里取网址的函数
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
    Private Function formatURL()Function formatURL(ByVal str As StringAs String
img_33d02437d135341f0800e3d415312ae8.gif        
Dim sStr As String
img_33d02437d135341f0800e3d415312ae8.gif        
Dim i As Integer
img_33d02437d135341f0800e3d415312ae8.gif        
Dim j As Integer
img_33d02437d135341f0800e3d415312ae8.gif        
For i = 1 To Len(str)
img_33d02437d135341f0800e3d415312ae8.gif            sStr 
= sStr & Mid(str, i, 1)
img_33d02437d135341f0800e3d415312ae8.gif            
If Mid(str, i, 1= "/" Then
img_33d02437d135341f0800e3d415312ae8.gif                j 
+= 1
img_33d02437d135341f0800e3d415312ae8.gif            
End If
img_33d02437d135341f0800e3d415312ae8.gif            
If j = 3 Then Exit For
img_33d02437d135341f0800e3d415312ae8.gif        
Next
img_33d02437d135341f0800e3d415312ae8.gif        
Return sStr
img_105a1e124122b2abcee4ea8e9f5108f3.gif    
End Function

img_33d02437d135341f0800e3d415312ae8.gif    
'将内容里的相对图片地址改成绝对地址的函数
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
    Private Function formatHtml()Function formatHtml(ByVal str As StringAs String
img_33d02437d135341f0800e3d415312ae8.gif        
Return Replace(str"src=" & Chr(34& "/""src =" & Chr(34& formatURL(TextBox1.Text))
img_105a1e124122b2abcee4ea8e9f5108f3.gif    
End Function

img_05dd8d549cff04457a6366b0a7c9352a.gif
End Class

当然还有好多功能没完成,比如收藏RSS地址、是否已读、自动更新。
所以叫简易RSS阅读器嘛!参考一下!

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
云计算
使用钉钉扫一扫加入圈子
+ 订阅

时时分享云计算技术内容,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。

其他文章