代碼如下,歡迎指正
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Xml;
using System.Collections;
namespace FinallyDemo
{
public partial class frmRSS : Form
{
public frmRSS()
{
InitializeComponent();
}
string url = "";
string xmlFilePath = "";
XmlDocument doc = new XmlDocument();
TreeNode tnroot = new TreeNode();
public void DownLoadXml(string url)
{
if(File.Exists(xmlFilePath))
{
File.Delete(xmlFilePath);
}
WebClient wc = new WebClient();
try
{
wc.DownloadFile(url, xmlFilePath);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
public void LoadXml()
{
if(File.Exists(xmlFilePath))
{
doc.Load(xmlFilePath);
XmlNode firstNode = doc.DocumentElement.FirstChild;
XmlNode root = firstNode.FirstChild;
treeView1.Nodes.Add(root.InnerText);
tnroot = treeView1.Nodes[0];
}
}
class Test
{
public string title;
public string url;