To help with the problem where the default namespace is not registered with the DOMXPath object, you can use the following replacement to update your paths accordingly:
<?php
$xml = <<<EOS
<root xmlns="urn:test">
<foo>bar</foo>
</root>
EOS;
$expression = '//foo';
$prefix = 'fakeprefix';
$doc = new DOMDocument();
$doc->loadXML($xml);
$context = $doc->documentElement; $xpath = new DOMXPath($doc);
if (null !== $context->namespaceURI) {
$xpath->registerNamespace($prefix, $context->namespaceURI);
$expression = preg_replace('#(::|/\s*|\A)(?![/@].+?|[a-z\-]+::)#', '$1' . $prefix . ':$2', $expression);
var_dump($expression); }
$foo = $xpath->query($expression, $context)->item(0);
var_dump($doc->saveXML($foo)); ?>