我使用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写入priveleges)
问题可能是“&”
原文链接:https://www.f2er.com/xml/293870.html$text=preg_replace('/&(?!#?[a-z0-9]+;)/','&',$text);
将摆脱“&”并用它的HTML代码版本替换它…试试。