I have a previously generated XML like this:
Fetch the node and use
instead of appending to the documentElement.
You can do that from the DOMDocument as well when passing in the shop node as second argument. Personally, I find it easier to just do that from the shop node because you have to fetch it anyway:
$shopNode->insertBefore($newNode);