[SOLVED] node->removeChild(); not working in our php 5.2.5
Posted: Sat Feb 02, 2008 11:08 pm
i do not know why but it is not working
error occurred at the bold line i do not know why?
the error is
Warning: DOMNode::removeChild() expects parameter 1 to be DOMNode, null given in
we should use this
Code: Select all
public function delete($x)
{
//echo("in function delete");
$dom = new DomDocument;
$dom->validateOnParse = true; // important, so we get the id listings from the dtd
$dom->load("sampleLink.xml");
$xpath = new DomXPath($dom);
$result = $xpath->query($x);
$linkNode = $result->item(0);
[b]$dom->getElementsByTagName("menu")->item(0)->removeChild($linkNode);[/b]
$dom->save("sampleLink.xml");
}
the error is
Warning: DOMNode::removeChild() expects parameter 1 to be DOMNode, null given in
we should use this
Code: Select all
$parentNode->removeChild($node); //removes the childNode