so i need to remove an element from an XML file using PHP. After some googling i found this question which i think put me on the right track. However when I run the code to delete the element, nothing happens. I don't get any error messages, and the node i have tried to delete is still there.
function deleteCourse($course){
echo "beginning delete";
$xml = self::getxml(); # get the XML file
$theCourse = $xml->xpath('course[name = "'.$course.'"]');
echo self::toJSON($theCourse[0]);
unset($theCourse[0]);
$xml->asXml("data.xml");
}
I've looked at the question I linked to and cannot see where i have gone wrong. Can anybody help me?