为什么XmlDocument.LoadXml抛出System.Net.WebException? [英] Why does XmlDocument.LoadXml throw System.Net.WebException?

查看:103
本文介绍了为什么XmlDocument.LoadXml抛出System.Net.WebException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 System.Xml.XmlDocument.LoadXml 法掷 System.Net.WebException

这真的是让人难以置信的疯狂,如果 MSDN 是正确的, loadXML的应该顶多给我一个 System.Xml.XmlException

不过,我有奇怪的例外,如:

  

基础连接已关闭:连接被意外关闭

 昏暗的文件作为新的XmlDocument
document.LoadXml(< D​​OCTYPE HTML PUBLIC! -  // W3C // DTD XHTML 1.0过渡// ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional。 DTD>&其中X  -  GT;&所述; / X>中)
MSGBOX(document.LastChild.Name)
 

这到底是怎么造成的例外呢?

解决方案

埃德温给你的解决方案,我现在给你的连接中断的原因:

http://www.w3.org/blog/systeam / 2008/02/08 / w3c_s_excessive_dtd_traffic /

Why does System.Xml.XmlDocument.LoadXml method throw System.Net.WebException ?

This is really mind boggling crazy, if MSDN was right, LoadXml should at most give me a System.Xml.XmlException.

Yet I have weird exceptions like:

The underlying connection was closed: The connection was closed unexpectedly.

Dim document As New XmlDocument
document.LoadXml("<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd""><x></x>")
MsgBox(document.LastChild.Name)

What on earth is causing the exception ?

解决方案

Edwin gave you the solution, and I'm giving you the reason for the connection drop:

http://www.w3.org/blog/systeam/2008/02/08/w3c_s_excessive_dtd_traffic/

这篇关于为什么XmlDocument.LoadXml抛出System.Net.WebException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆