Heim  >  Artikel  >  Backend-Entwicklung  >  php解析XML在5.2版本环境报错,5.3版本通常

php解析XML在5.2版本环境报错,5.3版本通常

WBOY
WBOYOriginal
2016-06-13 10:37:52926Durchsuche

php解析XML在5.2版本环境报错,5.3版本正常。
if (isset($_POST['xmldata'])) {
$string="".$_POST['xmldata']."";
$doc=$xml = new DOMDocument();
$xml->loadXML($string);
...
为什么我表单提交过来的XML文件,页面报错呢?
页面提示信息:
Warning: DOMDocument::loadXML() [domdocument.loadxml]: AttValue: " or ' expected in Entity, line: 2 in /usr/local/apache2/htdocs/dbmanage/xmlfile.php on line 126

Warning: DOMDocument::loadXML() [domdocument.loadxml]: attributes construct error in Entity, line: 2 in /usr/local/apache2/htdocs/dbmanage/xmlfile.php on line 126

Warning: DOMDocument::loadXML() [domdocument.loadxml]: Couldn't find end of Start Tag add line 2 in Entity, line: 2 in /usr/local/apache2/htdocs/dbmanage/xmlfile.php on line 126

Warning: DOMDocument::loadXML() [domdocument.loadxml]: AttValue: " or ' expected in Entity, line: 3 in /usr/local/apache2/htdocs/dbmanage/xmlfile.php on line 126

Warning: DOMDocument::loadXML() [domdocument.loadxml]: attributes construct error in Entity, line: 3 in /usr/local/apache2/htdocs/dbmanage/xmlfile.php on line 126

xml格式如下:
 
 
 
 
 
 
 
 


PHP版本:
#php -v
PHP 5.2.12 (cli) (built: Apr 25 2012 21:12:31)

------解决方案--------------------
var_dump($string); // 加上这句,贴出结果来。
$xml->loadXML($string);


------解决方案--------------------
表单POST上来的?enctype是什么? 还是AJAX提上来的? Content-Type设置了什么? 看看HTTP_RAW_POST_DATA?

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:phpMailer 中文乱码有关问题Nächster Artikel:thinphp脑袋引入