c#
我的代码
private void loadhtml()
{
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(Application.StartupPath + ("~doc.xml"));
XmlNodeList mynodelist;
XmlElement root = xmlDocument.DocumentElement;
mynodelist = xmlDocument.SelectNodes("/rss/channel/item");
int i = 0;
bool j;
string content = "";
StatusBar1.Text = "正在读取文章内容...";
i = listBox1.SelectedIndex;
label2.Text=listBox1.SelectedIndex.ToString();
if (content != null)
{
content = content + "<html><head><meta http-equiv='content-type' content='text/html;charset=UTF-8'></head><body>";
content = content + "<table width='100%' height='80' bgcolor='#eeeeee'><tr><td><b>标题:</b><a href='";
mynodelist = root.GetElementsByTagName("link");
content = content + mynodelist.Item(i).InnerXml;
content = content + "' target='_blank'>";
mynodelist = root.GetElementsByTagName("title");
content = content + mynodelist.Item(i).InnerXml;
content = content + "</tb></tr></table>";
mynodelist = root.GetElementsByTagName("description");
content = content + mynodelist.Item(i).InnerXml; content = content + "</body></html>";
}
j = SaveTextFile(Application.StartupPath + "~temp.html", content);
webBrowser1.Navigate(Application.StartupPath + "~temp.html");
StatusBar1.Text = "完成";
}
当我listbox.SelectedIndex到最后一项时 报错!!”未将对象引用到实例“
报错地址:“content = content + mynodelist.Item(i).InnerXml;”
高手指教???