query('//game[@id="' . $id . '"]')->item(0); $game->parentNode->removeChild($game); $count = $doc->getElementsByTagName("count")->item(0); $count->nodeValue = intval($count->nodeValue) - 1; $doc->save($path); header("Location: " . $_SERVER["HTTP_REFERER"]);