I'm trying to unset a node from a web.config file but it doesn't seem to be working. Anyone know what I'm doing wrong? If there's a better approche please let me know?
$web_config = simplexml_load_file('web.config');
$nodes = $web_config->children();
$att_name = 'myMap';
$value = '1';
$map_node = $nodes[0]->xpath( sprintf('rewrite/rewriteMaps/rewriteMap[@name="%s"]/add[@value="%d"]', $att_name, $value) );
print_r($map_node); // this outpus the correct node
if (!empty($map_node)) {
unset($map_node)
} else {
printf('No maps with value: "%d" found', $value);
}
$web_config->asXML();