Continue the last RSS reader.
Http://www.cnblogs.com/aowind/archive/2005/03/16/119841.html
This time, I made a special reader for the blog Park and added a treeview to the left to display the classification and blog list of the blog garden. Hey
Below are the pictures of the new version.
The source code provided last time
Http://www.cnblogs.com/aowind/archive/2005/03/17/120543.html
This time, only new content will be sent.
First, you need to add a treeview. Of course, you can decide where to add it. The general habit is to add it to me.
First, define a root node and two subnodes. The names are: blog garden, blog garden category, and blog garden list.
The following describes the process of reading the blog garden category: 'reading the blog garden category
Private Sub loadport ()
Dim I As Integer
Dim xmlPort As New XmlDocument
StatusBar1.Text = "reading blog garden category information"
XmlPort. Load ("http://www.cnblogs.com/CatalogOpml.aspx ")
XmlPort. Save (Application. StartupPath &"~ Port. xml ")
Dim Portnodelist As XmlNodeList
Portnodelist = xmlPort. SelectNodes ("/opml/body/outline ")
For I = 0 To Portnodelist. Count-1
TreeView1.Nodes. Item (0). Nodes. Item (0). Nodes. Add (Portnodelist (I). Attributes. ItemOf ("title"). InnerText ())
Next
StatusBar1.Text = "complete"
End Sub
I did not elaborate on many things last time, but I have to elaborate on it this time,
Bytes
Next, save a temporary file for later use.
TreeView1.Nodes. Item (0). Nodes. Item (1). Nodes. Add ()
This method adds a subnode to the first node under the root node of treeview1.
Listnodelist (I). Attributes. ItemOf ("title"). InnerText ()
This method is used to retrieve the value of the title attribute of the item whose INDEX is I in the node list in XML.
The next step is to read the blog list. You do not need to repeat the description to read the blog list.
Private Sub loadlist ()
Dim I As Integer
Dim xmlList As New XmlDocument
StatusBar1.Text = "reading blog list information"
XmlList. Load ("http://www.cnblogs.com/Opml.aspx ")
XmlList. Save (Application. StartupPath &"~ List. xml ")
Dim listnodelist As XmlNodeList
Listnodelist = xmlList. SelectNodes ("/opml/body/outline ")
For I = 0 To listnodelist. Count-1
TreeView1.Nodes. Item (0). Nodes. Item (1). Nodes. Add (listnodelist (I). Attributes. ItemOf ("title"). InnerText ())
Next
StatusBar1.Text = "complete"
End Sub
The next step is to process the selection event of the treeview node. The Private Sub treeviewappsafterselect () Sub treeviewappsafterselect (ByVal sender As System. Object, ByVal e As System. Windows. Forms. TreeViewEventArgs) Handles treeview1.
Select Case TreeView1.SelectedNode. Text
Case "blog garden category"
Loadport ()
Case "blog list"
Loadlist ()
Case "blog"
Case Else
Dim I, j As Integer
Dim xmltitle As New XmlDocument
Xmltitle. Load (Application. StartupPath &"~ Port. xml ")
Dim nodelist As XmlNodeList
Nodelist = xmltitle. SelectNodes ("/opml/body/outline ")
J = nodelist. Count-1
For I = 0 To j
If nodelist (I). Attributes. ItemOf ("title"). InnerText () = TreeView1.SelectedNode. Text Then
TextBox1.Text = nodelist (I). Attributes. ItemOf ("xmlUrl"). InnerText ()
Thread = New Thread (AddressOf loadrss)
Thread. Start ()
Exit
End If
Next
Xmltitle. Load (Application. StartupPath &"~ List. xml ")
Nodelist = xmltitle. SelectNodes ("/opml/body/outline ")
J = nodelist. Count-1
For I = 0 To j
If nodelist (I). Attributes. ItemOf ("title"). InnerText () = TreeView1.SelectedNode. Text Then
TextBox1.Text = nodelist (I). Attributes. ItemOf ("xmlUrl"). InnerText ()
Thread = New Thread (AddressOf loadrss)
Thread. Start ()
Exit
End If
Next
End Select
End Sub
The three processes are clear, hey! This function is complete.
Of course, other Opml import functions can be added.
The classification name here is dead. In fact, these can also be dynamically obtained.