日期:2014-05-17  浏览次数:20449 次

PHP无法显示XML页

PHP code

<?php 
        header('Content-Type: text/xml');
        echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>';
        echo '<response>';
        $name = $_POST['name'];
        echo 'hello '.htmlentities($name);
        echo '</response>';
    
?>



出错了。提示如下。

无法显示 XML 页。 
使用 XSL 样式表无法查看 XML 输入。请更正错误然后单击 刷新按钮,或以后重试。 


--------------------------------------------

Prolog 外部不能有 DOCTYPE 声明。处理资源 'http://127.0.0.1:8088/test/test.php' 时出错。第 2 行,位置: 11 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&...

------解决方案--------------------
你这段代码才8,9行,错误报的是第11行,我想八成是
PHP code
//这儿是否有HTML?有输出?
<?php 
        header('Content-Type: text/xml');

------解决方案--------------------
XML和HTML不能同时输出!

......
echo '</response>';
exit;
?>