‘xmlParseEntityRef:no name’在将xml加载到php文件时发出警告

前端之家收集整理的这篇文章主要介绍了‘xmlParseEntityRef:no name’在将xml加载到php文件时发出警告前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用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)

问题可能是“&”
$text=preg_replace('/&(?!#?[a-z0-9]+;)/','&amp;',$text);

将摆脱“&”并用它的HTML代码版本替换它…试试。

猜你在找的XML相关文章