2014-01-23 58 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文件適合這種情況。