2014-01-23 42 views
0

我是testingsimplexml_load_string()函数。simplexml_load_string XML错误

<?php 
ini_set('display_errors', '1'); 
$test = stripslashes($_POST['xml']); 
$testing = simplexml_load_string($test); 
print_r($testing); 
?> 

执行以下错误发生后,即使我是条纹斜线。

Warning: simplexml_load_string(): Entity: line 1: parser error : Malformed declaration expecting version in /var/www/check.php on line 5 

Warning: simplexml_load_string(): <?xml encoding='utf8'?><!DOCTYPE a[<!ENTITY e SYSTEM '/etc/passwd'>]><a>&e;</a> in /var/www/check.php on line 5 

Warning: simplexml_load_string():^in /var/www/check.php on line 5 

Warning: simplexml_load_string(): Entity: line 1: parser error : Blank needed here in /var/www/check.php on line 5 

Warning: simplexml_load_string(): <?xml encoding='utf8'?><!DOCTYPE a[<!ENTITY e SYSTEM '/etc/passwd'>]><a>&e;</a> in /var/www/check.php on line 5 

Warning: simplexml_load_string():^in /var/www/check.php on line 5 

Warning: simplexml_load_string(): Entity: line 1: parser error : Entity 'e' not defined in /var/www/check.php on line 5 

Warning: simplexml_load_string(): <?xml encoding='utf8'?><!DOCTYPE a[<!ENTITY e SYSTEM '/etc/passwd'>]><a>&e;</a> in /var/www/check.php on line 5 

Warning: simplexml_load_string():^in /var/www/check.php on line 5 

我该如何解决这个错误?

+0

您的XML无效。有可能你用'stripslashes()'自己破坏了它。 –

回答

0

我认为你正在尝试转换的xml文件格式不正确。您可以尝试第一个示例中官方文档here中的示例,然后尝试使您的XML文件适合这种情况。