System.Xml.XmlDocument,缓存外部依赖项 DTD 的最佳方法是什么?

发布于 2024-07-22 06:05:46 字数 209 浏览 2 评论 0原文

我正在将有效的 XHTML 加载到 XmlDocument 中,但加载需要 2 秒。 我发现如果我删除 DTD,它会立即生效,但随后我必须替换   到   等。声明的 HTML 实体数量很大,所以我觉得应该加载 DTD。 那么以最少的体力劳动预加载 DTD 的最简单方法是什么? 也许我可以将 DTD 作为资源文件放入程序集中并将其注入..? 有什么建议么?

I'm loading valid XHTML into an XmlDocument, but it takes 2 seconds to load. I've found that if I drop the DTD, it's instant, but then I have to replace   to  , etc. The number of declared HTML entities is large, so I feel the DTD should be loaded. So what is the easiest way to pre-load the DTD with minimal manual labor? Perhaps if I could, say, put the DTD into the assembly as a resource file and inject it in..? Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

素罗衫 2024-07-29 06:05:46

我在这里找到了一种技术,通过实现抽象类 XmlResolver 并将其设置为 XmlDocument 的 XmlResolver 属性。 抽象类实现返回所请求 URL 的 MemoryStream 对象,其中包含 DTD 或通常通过 HTTP 加载的任何其他资源。

http://www.codeproject.com/KB/XML/HTML2XHTML。 aspx?display=打印

I found a technique here, by implementing the abstract class XmlResolver and setting it to the XmlDocument's XmlResolver property. The abstract class implementation returns a MemoryStream object for the URL being requested, which contains the DTD or whatever other resource would normally be loaded over HTTP.

http://www.codeproject.com/KB/XML/HTML2XHTML.aspx?display=Print

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文