Use xmlDocGetRootElement when setting up namespaces.

The existing code uses doc->children, which is wrong in the case that the document has a doctype or PI nodes at the start.

This fix is originally from upstream issue #20, by kgrigsby59.

This changeset re-applies the fix on top of the nodesforxpath-namespacemappings branch (the two changes are in the same area of code).