A simple RSS reader written with VB.NET

xiaoxiao2021-03-06  15

The source code is as follows:

Imports System.xml Imports System.Threading Public Class Form1 Inherits System.Windows.Forms.Form #Region "Windows Form Designer Generated Code" Public Sub New () MyBase.New () This call is Windows Form Designer It is necessary. InitializationComponent () 'Add any initialized End Sub' form to clean up the component list after the initializeComponent () call. Protected Overloads Overrides Sub Dispose (ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose () End If End If MyBase.Dispose (disposing) End Sub 'Windows Form Designer Private components required As system.componentmodel.icontainer 'Note: The following procedure is required to use the Windows Form Designer to modify this process using the Windows Form Designer. 'Don't modify it using the code editor.

Friend WithEvents ListBox1 As System.Windows.Forms.ListBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents AxWebBrowser1 As AxSHDocVw.AxWebBrowser Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms. Label Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents StatusBar1 As System.Windows.Forms.StatusBar Friend WithEvents Label4 As System.Windows.Forms.Label Private Sub InitializeComponent () Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager (GetType (Form1)) Me.ListBox1 = New System.Windows.Forms.ListBox Me.Button1 = New System.Windows.Forms.Button Me.AxWebBrowser1 = New AxSHDocVw. AxWebBrowser Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.StatusBar1 = New System.Windows.Forms.StatusBar Me .Label4 = new system.windows.form s.Label CType (Me.AxWebBrowser1, System.ComponentModel.ISupportInitialize) .BeginInit () Me.SuspendLayout () '' ListBox1 'Me.ListBox1.Location = New System.Drawing.Point (0, 67) Me.ListBox1.Name = "ListBox1" me.listbox1.size = new system.drawing.size (727, 108) me.listbox1.tabindex = 0 '' Button1 'me.button1.location = new system.drawing.point (629, 5) ME .Button1.name = "Button1" me.button1.size = new system.drawing.size (94, 56) me.button1.tabindex = 1 me.button1.text = "Read" '' AxWebBrowser1 'me.axwebbrowser1. Enabled = true me.axwebbrowser1.location =

New System.Drawing.Point (-7, 184) Me.AxWebBrowser1.OcxState = CType (resources.GetObject ( "AxWebBrowser1.OcxState"), System.Windows.Forms.AxHost.State) Me.AxWebBrowser1.Size = New System. Drawing.size (727, 480) me.axwebbrowser1.tabindex = 2 '' label1 'me.label1.location = new system.drawing.point (0, 26) me.label1.name = "label1" me.label1.size = New system.drawing.size (624, 15) me.label1.tabindex = 3 me.label1.text = "Website address:" 'Label2' me.label2.location = new system.drawing.point (0, 45 ) Me.label2.name = "label2" me.label2.size = new system.drawing.size (624, 14) me.label2.tabindex = 4 me.label2.text = website description: "'TextBox1' ME .TextBox1.Location = new system.drawing.point (72, 0) me.textbox1.name = "textbox1" me.textbox1.size = new system.drawing.size (552, 20) me.textbox1.tabindex = 6 me .Textbox1.text = "http://blog.9cbs.net/applebbs/rss.aspx" 'statusbar1' me.statusbar1.location = new system.drawing.point (0, 495) me.statusbar1.name = " Statusbar1 "me.statusbar1.size = new system.drawing. Size (726, 22) me.statusbar1.tabindex = 7 me.statusbar1.text = "statusbar1" '' Label4 'me.label4.location = new system.drawing.point (0, 6) me.label4.name = " Label4 "me.label4.size = new system.drawing.size (72, 12) me.label4.tabindex = 8 me.label4.text =" RSS address: "me.label4.textalign = system.drawing.contentalignment.middleleleft '' Form1 'me.autoscalebasesize = new system.drawing.size (5, 13) me.clientsize =

New system.drawing.size (726, 517) me.controls.add (me.statusbar1) me.controls.add (Me.TextBox1) me.controls.add (me.label2 Me.Controls.add (me.label1) me.controls.add (me.axwebbrowser1) me.controls.add (me.button1) me.controls.add (me.listbox1) me.name = "form1" me. StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Easy RSS Reader" CType (Me.AxWebBrowser1, System.ComponentModel.ISupportInitialize) .EndInit () Me.ResumeLayout (False) End Sub #End Region Private thread As Thread 'Defines a thread private subs ()' to read the RSS file and remove the content headline Statusbar1.text = "& TextBox1.text &" is being read "& TextBox1.text &" "me.loadxmltocache (TextBox1.text) statusbar1.text = "Reading related website information" me.loadtitle () statusbar1.text = "Phase RSS content item" me.loadItem () statusbar1.text = "Complete" End Sub Private Sub Button1_Click (Byval Sender As System. Object, byval e as system.eventargs) Handles Button1.Click Try Thread = new thread (addressof loadrs) thread.start () catch exception msgbox (ex.toswoting) End Try end Sub Private Sub Form1_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AxWebBrowser1.Width = Me.Width StatusBar1.Text = "Ready" End Sub Private Sub loadxmltocache (ByVal URL As String) 'read Take the RSS file and store it locally for operation DIM XMLDocument as new xmldocument Xmldocument.Load (URL) XMLDocument.save (Application.Startuppath & "~ DOC.XML") End Sub Private Sub LoadTitle () Operation from the local file read the information in RSS Dim website xmlDocument As New XmlDocument xmlDocument.Load (Application.StartupPath & "~ doc.xml") Dim mynodelist As XmlNodeList mynodelist = xmlDocument.SelectNodes ( "/ rss / channel"

) Label1.text = "Website:" & Trim (MyNodelist (0) .Innertext ()) label2.text = "Description:" & Trim (MyNodelist (0) .Item ("description") .Innertext ()) End Sub Private Sub LoadItem () 'Operation from the local file, read the title of the content in the RSS and the author DIM XMLDocument as new xmldocument xmldocument.load (Application.Startuppath & "~ Doc.xml") DIM MyNodelist As XMLnodelist MyNodeList = XmLDocument.selectNodes ("/ RSS / Channel / Item") listbox1.items.clear () Dim i as integer for i = 0 to mynodelist.count - 1 ListBox1.Items.Add ("[" & TRIM (MyNodeList (i) .Item ("DC: Creat"). InnerText ()) & "]" & Trim (INODELIST (i) .Innertext ()) Next End Sub Private Sub ListBox1_selectedIndexchanged ( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged thread = New Thread (AddressOf loadhtml) thread.Start () End Sub Private Sub loadhtml () 'read RSS content corresponding to the temporary files coexist Display DIM XMLDocument as new xmldocument xmldocument.load (Application.Startuppath & "Doc.xml") DIM MyNodelist as XMLNodelist MyNodeList = XmLDocument.select Nodes ("/ r s / channel / item") DIM I as INTEGER DIM J AS Boolean Dim Content AS String Statusbar1.Text = "Reads Article Content" for i = 0 to mynodelist.count - 1 if listbox1.selecteditem = " ["& TRIM (i) .Item (" DC: Creat "). InnerText ()) &"] "& trim (I) .Inode (" Title "). InnerText ()) THEN Content = Content () & "

'0' Right Margin = '0'> "Content = Content &"

Title: "Content = Content & Trim (MyNodelist (i) .Item (" title ".) InnerText ()) content = content &"
OF: "content = content & Trim (mynodelist (i) .Item (" dc: creator "). InnerText ()) Content = Content & "
Date: " Content = Content & Trim (MyNodelist (i) .Innertext ()) Content = Content & "< / TD>
summary: "Content = Content & Formathtml (MyNodelist (i) .Item (" Description "). InnerText )) Content = Content & " " j = savetextfile (application.startuppath & "temp.html", content) AXWebBrowser1.naviGate (Application .Startuppath & "~ temp.html") EXIT for end if next statusbar1.text = "Complete" End sub 'write file process Function SavetextFile (Byval Filepath As String, BYVAL FileContent As String) AS Boolean Dim SW as System.io .Streamwri Ter try sw = new system.io.Streamwriter (filepath, false) sw.write (filecontent) Return True catch e AS exception returnif false Finally if not swipe nothing the sw.close () End Try End Function '

转载请注明原文地址:https://www.9cbs.com/read-46314.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.042, SQL: 9