clean up libxml/dom/simplexml

- Move 2 php_libxml_* functions to their appropriate place to
  reflect Zend (libxml extension).
- Call these functions from SimpleXML to properly clean up after
  ourselves, which earlier was incorrect assumed to be entirely
  handled by xmlFreeDoc in sweeps.
- Don't NULL out node->doc, this should only be done at refcount 0 to
  prevent double frees. XML extensions take care of this themselves.

There's still a bunch of work needed to be done: SimpleXML and
DOMDocument share a lot more functionality that should eventually be
moved to libxml as well.

That will be a gradual process however, and this change plugs a leak in
the meantime.