我有一個XML文件(scores.xml),即時通訊使用PHP代碼添加新的標籤。PHP提交錯誤的代碼到XML
我有一個標籤叫頭包含一些HTML代碼
<![CDATA[<tr><td colspan='7' id='headertd'>
<img border='0' src='images/euro.png' />
UEFA Euro 2012 Qualifications</td></tr>]]>
當我寫在PGP腳本的形式驗證碼和submiting一切正常,除了標題標籤中的XML文件... 。IM得到一個錯誤的PHP腳本,代碼會在那樣的XML標籤:
<![CDATA[<tr><td colspan='7' id='headertd'>
<img border='0' src='images/euro.png' />
UEFA Euro 2012 Qualifications</td></tr>]]>
因此多數民衆贊成讓錯誤的信息給我的XML ... 有反正我可以解決這一問題?並避免這些代碼的轉換?
這就是我的PHP代碼:
<?php
if (isset($_POST['submitted'])) {//If the user submitted the form, then add to the XML file
//Load the scores XML file
$scores = new DOMDocument();
$scores -> load('../scores.xml');
//Get the <Games> tag
$games = $scores -> getElementsByTagName('Games');
//Create the new <Game> tag
$newGame = $scores -> createElement("Game");
$newGame -> appendChild($scores -> createElement("Header", $_POST['header']));
//Add the new <Game> tag under the <Games> tag
$games -> item(0) -> appendChild($newGame);
//Save again
$scores -> save('../scores.xml');
echo "New game added.";
}
?>
<form id="form1" method="post" action="">
Header: <textarea style=" color:#000;" name="header" cols="73" rows="6" > </textarea>
<br><input type="submit" name="submitted" name="Add new row">
</form>
我有沒有用戶界面的即時通訊只是使用該腳本,使工作更容易爲我張貼在我的網站上的東西!
您的幫助非常感謝!
在此先感謝!
是更好嗎?:) – Chta7