【发布时间】:2019-08-03 15:55:47
【问题描述】:
我有一个类似的 XML 文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE note SYSTEM "Note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget &xyz me this weekend!</body>
</note>
这里说 &xyz 是一个在 Note.dtd 文件中声明的实体。但是当我尝试这个时,它给了我一个错误 - 引用未声明的实体 'xyz'。
XmlDocument doc = new XmlDocument();
doc.Load(filePath); // Error is thrown at this line
XmlDocument 不检查外部引用的 dtds 吗?如何解决这个问题?
【问题讨论】:
-
DTD 是否在正确的位置?这个文件的内容是什么样的?
-
不应该是
&xyz;,末尾有分号才有效吗?
标签: c# xml dtd xmldocument