【发布时间】:2011-11-28 02:23:51
【问题描述】:
我正在使用simplexml_load_file 在 php 中读取 xml。但是,在尝试加载 xml 时,它会显示警告列表
Warning: simplexml_load_file() [function.simplexml-load-file]: <project orderno="6" campaign_name="International Relief & Development" project in /home/bluecard1/public_html/test.php on line 3
Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /home/bluecard1/public_html/test.php on line 3
Warning: simplexml_load_file() [function.simplexml-load-file]: http://..../index.php/site/projects/:15: parser error : xmlParseEntityRef: no name in /home/bluecard1/public_html/test.php on line 3
Warning: simplexml_load_file() [function.simplexml-load-file]: ional Relief & Development" project_id="313" client_name="International Relief & in /home/bluecard1/public_html/test.php on line 3
Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /home/bluecard1/public_html/test.php on line 3
Warning: simplexml_load_file() [function.simplexml-load-file]: http://..../index.php/site/projects/:15: parser error : xmlParseEntityRef: no name in /home/bluecard1/public_html/test.php on line 3
如何纠正以删除这些警告?
(XML 是从 url http://..../index.php/site/projects 生成并加载到 test.php 中的变量中。我没有写权限到 index.php)
【问题讨论】:
-
XML 无效。您可能根本无法加载它。可以通过在
simplexml_load_file前面添加@或添加标志来抑制错误,有关详细信息,请参阅simplexml_load_file的手册页,请删除您的问题,这是重复的。 -
我可以看到我的答案受到了很多关注,如果这实际上是解决方案:您能否将其标记为“正确答案”?谢谢。