XML/PHP:序言中不允许有内容 [英] XML/PHP : Content is not allowed in prolog
问题描述
我收到此消息错误,但不知道问题出在哪里:
i have this message error and i don't know where does the problem comes from:
<?php include "DBconnection.class.php";
$sql = DBConnection::getInstance();
$requete = "my resquest (which is working)";
$sql->query($requete);
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml .='<GamerCertified>';
while($row = $sql->fetchArray()){
$moyenne_services = ($row['services'] + $row['serviceCli'] + $row['interface'] )/3;
$moyenne_services = round( $moyenne_services,1);
$moyenne_ge = ($row['services'] + $row['serviceCli'] + $row['interface'] + $row['qualite'] + $row['rapport'] ) /5;
$moyenne_ge = round( $moyenne_ge,1);
$xml .= '<GSP>';
$xml .= '<nom>'.$row["nom"].'</nom>';
$xml .= '<votes>'.$row["nb_votes"].'</votes>';
$xml .= '<services>'.$moyenne_services.'</services>';
$xml .= '<qualite>'.$row["qualite"].'</qualite>';
$xml .= '<prix>'.$row["rapport"].'</prix>';
$xml .= '<transparence>'.$row["transparence"].'</transparence>';
$xml .= '<moyenneGenerale>'.$moyenne_ge.'</moyenneGenerale>';
$xml .= '<serveursDedies>'.$row["offreDedie"].'</serveursDedies>';
$xml .= '</GSP>';
}
$xml .= '</GamerCertified>';
echo $xml;
谢谢
(PS:FF/chrome 回显无标签:bc2x56.99.89.8081ckras1710.09.0080crazy-fun-game11010.010.00100crystal-serv349.79.69.509.60didicore69.49>p.dicore381.69
(PS: FF /chrome echoes that without tag : bc2x56.99.89.8081ckras1710.09.0080crazy-fun-game11010.010.00100crystal-serv349.79.69.509.60dedicore69.49.38.609.21)
推荐答案
我认为问题出在其他地方.尝试使用以下代码:
I think the problem is somewhere else. Try using the following code:
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
代替:
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
这是因为您将整个 XML 文本存储在一个 PHP 变量中,这有时会出错.
This is because you are storing the whole XML text in a PHP variable, which sometimes go awry.
另外请注意不要在 XML 开始标记 (<?xml
...) 之前打印任何空白字符.并且只需在 XML 定义结束标记 (...encoding="UTF-8"?>
) 后使用一个回车符(如键盘的回车"键),即可开始您的 XML 的第一个开始标记 (
).
Also please take care that you don't print any whitespace character before the XML start tag (<?xml
...). And just use one carriage return (like the "enter" key of your keyboard) after the XML definition end tag (...encoding="UTF-8"?>
), so as to start your XML's first start tag (<GameCertified>
).
希望有帮助.
这篇关于XML/PHP:序言中不允许有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!