First off, what exception are you getting (It likely matters).
As for the specific problem, my guess would be as follows::
The $node
is not a child of the document. It's a child of its parent. So you'd need to do:
$node->parentNode->removeChild($node);