php xml eacute错误

nuc*_*ker 4 php xml

请帮帮我.我有这个错误

<Name>secret CAKES &amp; CAF&Eacute;
imited</Name>
XML Parsing Error: undefined entity
Location: http://localhost/xml.php
Run Code Online (Sandbox Code Playgroud)

在我的PHP

htmlentities($row['companys'],ENT_QUOTES) 
Run Code Online (Sandbox Code Playgroud)

Gre*_*reg 8

&Eacute; 是一个有效的HTML实体,但不是有效的XML实体(除非您定义它)​​.

htmlspecialchars改用.

确保您的XML文档也定义了正确的字符集.


Rub*_*ias 5

您的 XML 文件无效,因为&Eacute;它不是 XML 文档的默认字符实体。

您应该将其替换为&#201;或对其进行正确编码。


Add*_*dsy 2

É 是一个 html 实体,而不是 xml 实体,因此您只能在 html 或 xhtml 文档中使用它,而不能在 xml 文档中使用它。

\n\n

xml中只定义了5个实体

\n\n

http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML

\n\n

您应该在 xml 文档中将所有其他实体保留为 unicode 字符,然后如果您需要将它们转换为 html 实体,请在显示 xml 中的数据时执行此操作,而不是在创建 xml 文档时执行此操作(即,这样 \xc3\ xa9是解析xml后转换的)

\n\n

或者,您可以在 xml 文档中定义其他 html 实体。php htmlentities页面上的这条评论使用了这个方法

\n\n

http://www.php.net/manual/en/function.htmlentities.php#84327

\n