这是上传要验证的 XML 文档的代码。此代码在包含代码的行中给出了一些异常问题
xmlDoc.Load(reader);
。
特定的异常消息是“用户代码未处理异常”。
private void btnLoad_Click(object sender, System.EventArgs e)
{
XmlTextReader reader = new XmlTextReader(Server.MapPath("mycompany.xml"));
reader.WhitespaceHandling = WhitespaceHandling.None;
XmlDocument xmlDoc = new XmlDocument();
//Load the file into the XmlDocument
xmlDoc.Load(reader);
//Close off the connection to the file.
reader.Close();
//Add and item representing the document to the listbox
lbNodes.Items.Add("XML Document");
//Find the root nede, and add it togather with its childeren
XmlNode xnod = xmlDoc.DocumentElement;
AddWithChildren(xnod,1);
}