PHP输出XML实例(是输出,不是生成)

网络整理 - 08-28

以下为引用的内容:
<?php
header('Content-Type: text/xml');
include"../config.inc.php";   
$obj = new dbConnection();
$sql = "select * from Union_Data order by Data_gengxintime limit 100";
$result = $obj -> Connection($sql);
$xml="";
while($arrRow = mysql_fetch_assoc($result)){
    $xml .= "<union_data>\n";
    $xml .= "<Data_id>".$arrRow["Data_id"]."</Data_id>\n";
    $xml .= "<Data_pianming>".$arrRow["Data_pianming"]."</Data_pianming>\n";
    $xml .= "<Data_bieming>金刚</Data_bieming>\n";
    $xml .= "<Data_leibie>2</Data_leibie>\n";
    $xml .= "<Data_leixing>27</Data_leixing>\n";
    $xml .= "<Data_diqu>美国</Data_diqu>\n";
    $xml .= "<Data_daoyan>导演</Data_daoyan>\n";
    $xml .= "<Data_zhuyan>主演</Data_zhuyan>\n";
    $xml .= "<Data_shouying>2006</Data_shouying>\n";
    $xml .= "<Data_pianchang>120</Data_pianchang>\n";
    $xml .= "<Data_jishu>1</Data_jishu>\n";
    $xml .= "<Data_peiyin>英语</Data_peiyin>\n";
    $xml .= "<Data_zimu>中文</Data_zimu>\n";
    $xml .= "<Data_shuoming></Data_shuoming>\n";
    $xml .= "<Data_miaoshu>描述暗暗暗暗暗暗</Data_miaoshu>\n";
    $xml .= "<Data_zhuangtai>0</Data_zhuangtai>\n";
    $xml .= "<Data_haibao>61465148.jpg</Data_haibao>\n";
    $xml .= "<Data_dianji>1</Data_dianji>\n";
    $xml .= "<Data_tuijian>1</Data_tuijian>\n";
    $xml .= "<Data_shenhe>1</Data_shenhe>\n";
    $xml .= "<Data_lurenzhe>admin</Data_lurenzhe>\n";
    $xml .= "<Data_gengxintime>2009-02-23 17:47:56</Data_gengxintime>\n";
    $xml .= "<Data_tianjiatime>2009-02-23 15:32:50</Data_tianjiatime>\n";
    $xml .= "</union_data>\n";
}
//echo $xml;
//exit;
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
echo "<data>\n";
echo $xml;
echo "</data>";
?>