- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我在我们的一个项目网页中有以下代码:
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);
}
它基本上需要一个 xml 批处理文件并将其加载为一个对象,准备好进行处理。
它一直运行良好,直到最近发现其中一个 XML 文件包含空字符(这在 XML 中是无效的)。
当它试图处理这个“dudd”文件时,我们得到以下异常:
alt text http://blog.ianmellor.co.uk/images/xml_err.jpg
到此为止......但是当我们尝试“继续”或“跳过”时,我希望它流入 catch block 。然而,事实并非如此;我们只是得到了死亡的红屏:
alt text http://blog.ianmellor.co.uk/images/xml_err2.jpg
我做错了什么?
最佳答案
那是因为你没有写
xDoc.Load(File.FullName);
在 try block 中。这就是未处理异常的原因。
关于c# - 似乎无法处理 XMLException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1404447/
我第一次尝试使用 SoapUI 5.3.0。这是我所做的: 创建了一个默认的 WCF 项目并将其发布到 IIS。 确保我可以在此处访问 WSDL:http://MyComputer/WCFTest/S
我在 soapUI 中创建新项目并从 URL 导入 wsdl 文件时遇到问题。它给了我以下异常 加载错误 [ http://localhost:8080/WS/PersonalDetails.xsd]
背景 我序列化了一个非常大的 List使用此代码: public static string SerializeObjectToXML(T item) { XmlSerializer xs =
我在我们的一个项目网页中有以下代码: XmlDocument xDoc = new XmlDocument(); xDoc.Load(File.Full
我正在编写一个 XML 代码编辑器,我想在用户界面中显示语法错误。因为我的代码编辑器强烈受限于特定的问题域和受众,所以我想重写某些 XMLException 消息以对用户更有意义。例如,像这样的异常消
我正在制作一个 Web 应用程序,它从网站(URL 在数据库中)获取 RSS 提要,然后将它们加载到我的 Web 应用程序中。但是我收到了这个错误 System.Xml.XmlException: R
我正在 Silverlight 项目中使用 XmlReader 编写文件阅读器。但是,我遇到了一些错误(特别是关于 XmlReader.ReadStartElement 方法),这让我相信我误解了如何
所以当我尝试从文件创建 XDocument 时出现此错误,但问题是它只发生大约 20% 的时间,但我的程序需要调用这个创建 XDocument 的函数20 秒,所以这是修复的关键。 这是我的函数从文件
在测试接受字符串并将该字符串作为属性添加到 XElement(将当前时间作为值)的方法的过程中。要使用 XElement.SetAttributeValue(XName name, object va
我的代码中有几个地方抛出新的 System.Xml.XmlException 似乎是合适的。我可以做 throw new XmlException("Your XML sucks go fix it
我试图从 WP7 中的 XML 文档中读取并遇到了一个我根本没有得到的奇怪错误,当我在重新启动 WP7 模拟器后第一次运行我的程序时,但是如果我运行它在不关闭模拟器的调试中,它给我运行时错误:'Xml
我有一个要持续运行的 EWS 流媒体订阅。它等待特定收件箱中的新邮件事件,当事件触发时,它会读取电子邮件并将内容发布到不同的 Web 服务。在大多数情况下,这很好用,但是每次抛出此 System.Xm
本文整理了Java中org.exolab.castor.xml.XMLException.()方法的一些代码示例,展示了XMLException.()的具体用法。这些代码示例主要来源于Github/S
本文整理了Java中org.exolab.castor.xml.XMLException.getMessage()方法的一些代码示例,展示了XMLException.getMessage()的具体用法
创建 XML 文件时,有几个关于此的 SO 问题和答案;但是找不到任何关于何时从必须处理的第 3 方获得错误 XML 的信息;请注意,第三方不对非法 XML 负责。 最终,需要对 .InnerText
此示例代码: var json = JsonConvert.SerializeObject(new XmlException("bla")); var exception = JsonConvert.
本文整理了Java中org.apache.shindig.common.xml.XmlException.()方法的一些代码示例,展示了XmlException.()的具体用法。这些代码示例主要来源于
本文整理了Java中org.apache.shindig.common.xml.XmlException.getMessage()方法的一些代码示例,展示了XmlException.getMessag
我尝试做一些理论上非常简单的事情:将字符串反序列化为消息,这是代码: [TestMethod] public void EncoderErrorTest() { var message = "
我们的网站上有一个自定义 STS,它们都在 Windows Azure 中运行。 STS 是 ASP.NET 4.0,站点是 MVC3。在过去的几天里,我开始在我们的诊断日志中看到以下异常情况: Sy
我是一名优秀的程序员,十分优秀!