我一直在构建一个返回 XML 代码的 API。例如,API 将返回:
<message>hello, this is a message & it used htmlsepcialchars</message>
我正在使用 file_get_contents() 和 simplexml_load_string() 将返回的信息加载到数组中。
然后我使用 utf8_decode() 将消息转换为接收网站上的友好字符集。但是,我收到以下消息,其中 pin 指向消息中的 & 符号:
Warning: main() [function.main]: unterminated entity reference
由于与号,消息的其余部分被截断。任何想法如何解决这个问题?