我正在動態生成xml
文件,並且在包含時出現錯誤newstext。 Error: XML Parsing Error: undefined entity
!
刪除newstextxml
生成完美。這是我使用的代碼。在PHP中動態生成XML - 解析錯誤
$sqlNews = "SELECT * FROM news";
$runSqlNews = mysql_query($sqlNews);
while ($rowSqlNews = mysql_fetch_array($runSqlNews))
$arrSqlNews[] = $rowSqlNews;
header('Content-type: text/xml');
header('Pragma: public');
header('Cache-control: private');
header('Expires: -1');
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
echo '<xml>';
for($i=0;$i<count($arrSqlNews);$i++)
{
echo "<news>";
echo "<newsId>".$arrSqlNews[$i][id]."</newsId>";
echo "<newsAuthor>".$arrSqlNews[$i][news_author]."</newsAuthor>";
echo "<newsText>".$arrSqlNews[$i][news_text]."</newsText>";
echo "<description>".$arrSqlNews[$i][news_description]."</description>";
echo "<image>".$arrSqlNews[$i][news_image]."</image>";
echo "</news>";
}
echo '</xml>';
希望我的問題很清楚。提前致謝 !!
PHP有幾個擴展來生成XML,負責生成有效的語法...... –