請幫我與替換子節點替換子節點的值PHP的XML-DOM
$dom = new DOMDocument();
$dom->load('cheat.xml');
$team1sabbr = $dom->getElementsByTagName('team1sabbr');
$textNode = $dom->createTextNode('value-1');
$textNode = $dom->importNode($textNode, true);
$team1sabbr->replaceChild($textNode, $oldNode);
$dom->save('cheat.xml');
它扔像
Fatal error: Call to undefined method DOMNodeList::replaceChild()
cheat.xml
錯誤看起來像
<?xml version="1.0"?>
<matches>
<match id="2204">
<Game></Game>
<team1sabbr></team1sabbr>
<team2sabbr></team2sabbr>
什麼是'$ oldNode'?它在哪裏定義? – 2012-03-03 08:23:36
@Martin哦......我剛剛從某處複製了代碼並使用它,請問您能否展示如何定義它。謝謝。 – krishna 2012-03-03 08:34:01
在這種情況下,我可能會收到此錯誤,以及 – krishna 2012-03-03 08:39:06