simplexml_load_string XML错误

时间:2014-01-23 16:27:07

标签: php xml

我是testingsimplexml_load_string()func。

<?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

我如何解决这个错误?

1 个答案:

答案 0 :(得分:0)

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