DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Functions To Add / Remove Nodes To / From An XML File Using PHP.
// description of your code here
<?php
function removNode($myXML, $node, $attribute, $id) {
$xmlDoc = new DOMDocument();
$xmlDoc->load($myXML);
$xpath = new DOMXpath($xmlDoc);
if( $attribute!='' || $id!='' )
$nodeList = $xpath->query('//'.$node.'[@'.$attribute.'="'.$id.'"]');
else
$nodeList = $xpath->query('//'.$node.'');
if ($nodeList->length)
{
$node = $nodeList->item(0) ;
$node->parentNode->removeChild($node);
}
$xmlDoc->save($myXML) ;
}
?>
<a href="http://www.freemanagementgames.com"> Management Games </a>





