Sk9*_*k93 5 c# xml asp.net exception
我在我们的一个项目网页中有以下代码:
XmlDocument xDoc = new XmlDocument();
xDoc.Load(File.FullName);
//work through each print batch in this queue file
try
{
XmlNodeList nodeList = xDoc.SelectNodes("Reports/PrintBatch");
foreach (XmlNode printBatch in nodeList)//xDoc.SelectNodes("Reports/PrintBatch"))
{
PrintBatch batch = new PrintBatch();
batch.LoadBatch(printBatch, File.Extension);
this.AddBatch(batch);
}
}
catch (XmlException e)
{
//this report had an error loading!
Console.WriteLine(e.Message);
}
Run Code Online (Sandbox Code Playgroud)
它基本上需要一个xml批处理文件并将其作为对象加载,准备进行处理.
它一直工作正常,直到最近才发现其中一个XML文件包含一个空字符(在XML中无效).
当它试图处理这个"dudd"文件时,我们得到以下异常:
alt text http://blog.ianmellor.co.uk/images/xml_err.jpg
好到目前为止..但是当我们尝试"继续"或"跳过"时,我希望它会流入catch块.但是,它没有; 我们只是得到死亡的红屏:
alt text http://blog.ianmellor.co.uk/images/xml_err2.jpg
我究竟做错了什么?