DomXPath and default XML namespaces
[email protected] (Dan Phiffer) Mon, 13 Dec 2004 19:56:16 -0800
| Newsgroups | php.general,php.xml.dev |
|---|---|
| Message-ID | <[email protected]> |
I'm curious whether it's possible to use the DomXPath->query in such a
way that this...
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<div>Foo</div>
</body>
</html>
.. could be accessed like this:
$xp = new DomXPath($domdoc);
echo $xp->query("/html/body/div")->item(0)->nodeValue;
... instead of like this:
$xp = new DomXPath($domdoc);
$xp->registerNamespace('html', 'http://www.w3.org/1999/xhtml');
echo $xp->query("/html:html/html:body/html:div")->item(0)->nodeValue;
I guess what I would expect to work is to allow for blank values as the
first argument to registerNamespace, representing the default namespace,
but that causes the queries to always return no matches. Is there
something I'm missing with this?
Thanks!
-Dan