请帮我与替换子节点替换子节点的值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