For those transitioning to PHP5 DOM XML code, there is a gotcha with this function.
In PHP4, when you call $node->set_content($string), the $string must have special HTML characters encoded. The method does not properly handle the "&" character, so this is required to properly set the content
In PHP5, when you call $node->appendChild($dom->createTextNode($string)), PHP will properly encode the "&" character without the need for HTML encoding.
Because of this, older code that is currently using htmlspecialchars() in the set_content() call will potentially double-encode the "&" character if you keep the call to htmlspecialchars() in the createTextNode() call.