XML解析问题用C#的LINQ to XML - 引用了未声明的实体

问题描述:

试着解析XML文件给了我下面的错误 引用了未声明实体“eacute”XML解析问题用C#的LINQ to XML - 引用了未声明的实体

我创建后DTD文件的所有我发现这里http://www.w3.org/TR/xhtml1/dtds.html实体和我装好了如下

XmlReaderSettings settings = new XmlReaderSettings(); 
settings.ProhibitDtd = false; 
string s = System.IO.File.ReadAllText(@"..\xhtml-lat1.ent"); 
XmlParserContext con = new XmlParserContext(null, null, "iti", null, null, s, "", "", XmlSpace.None); 
XmlReader reader = XmlReader.Create(stream, settings, con); 

加载一个XDocument

XDocument doc = XDocument.Load(reader); 

给我以下例外'='是一个意外的标记。预期的标记是';'。

任何建议请

一般来说,当XML文档格式不正确会发生这种错误。

一个提示找到错误,在Internet Explorer中打开您的xml文档。如果xml文档格式不正确,Internet Explorer将无法加载整个文档,并会告诉您错误的位置。

+0

是的Internet Explorer是给出同样的错误 – 0xFF 2009-07-12 22:30:02

如果我记得没错,XML中分号唯一的地方就是实体编码。我会检查一个不完整的实体(可能是& eacute)或文档中应该被编码的特殊字符。