ó not allowed in xml file but allowed in .net resource file?

独自空忆成欢 提交于 2019-12-22 11:15:29

问题


i'm parsing a few .net resource files (.resx).

In that, i have this piece of data:

información

This works in my .net app, but when i try to load this file in my xml document

XDocument xmlDoc = XDocument.Parse(s);

i get this error:

Reference to undeclared entity 'oacute'. 

Why is that?


回答1:


ó is a named HTML entity that is not defined in XML.

XML only defines a subset of the named HTML entities (namely &, ', ", > and < if memory serves).

You can use the numeric entity representation instead:

información

Or, in hexadecimal:

información



回答2:


The entity oacute is not declared by default for XML. Try ó instead. Here is a list of HTML entities with their corresponding codes, in case you have other similar problems.

If you'd prefer to continue using ó, you can define the entity yourself.

If you are using a DTD, you can define it thus

<!ENTITY oacute "&#243;">

Or if using Schema, thus:

<xsd:element name="oacute" type="xsd:token" fixed="&#243;"/>


来源:https://stackoverflow.com/questions/4656121/oacute-not-allowed-in-xml-file-but-allowed-in-net-resource-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!