simpleXML和实体未定义的问题 [英] Problem with simpleXML and entity not being defined

查看:51
本文介绍了simpleXML和实体未定义的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解析XML文件,但是在加载它时,simpleXML会显示以下警告:

I'm trying to parse a XML file, but when loading it simpleXML prints the following warning:

警告:simplexml_load_file()[function.simplexml-load-file]:gpr_545.xml:55:解析器错误:在第35行的import.php中未定义实体'Oslash'

Warning: simplexml_load_file() [function.simplexml-load-file]: gpr_545.xml:55: parser error : Entity 'Oslash' not defined in import.php on line 35

这是那一行:

<forenames>B&Oslash;IE</forenames><x> </x>

这是一个警告,我可能会忽略它,但我想了解发生了什么.

As it is a warning, I might ignore it, but I'd like to understand what is happening.

推荐答案

Latin1字符(如Ø,该字符描述的内容)的HTML编码破坏了XML解析器.如果您要控制数据,则需要使用XML样式字符编码对其进行转义(Ø恰好是&#216;)

HTML Encoding of Latin1 characters (like Ø, what that character describes) is what has broken the XML parser. If you're in control of the data, you need to escape it using XML style character encoding (Ø just happens to be & #216;)

这篇关于simpleXML和实体未定义的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆