#39505 [Opn->Bgs]: xpath query failed if root element has xmlns attribute
| From: | rrichards@php.net | Date: | Mon, 13 Nov 2006 20:50:06 +0000 |
| Subject: | #39505 [Opn->Bgs]: xpath query failed if root element has xmlns attribute | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-104929@lists.php.net to get a copy of this message | ||
ID: 39505
Updated by: rrichards@php.net
Reported By: sghnqk at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: DOM XML related
Operating System: linux
PHP Version: 5.2.0
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
first case is correct - xpath is namespace aware and root in def ns.
Previous Comments:
------------------------------------------------------------------------
[2006-11-13 19:08:15] sghnqk at gmail dot com
Description:
------------
according to http://www.w3.org/TR/REC-xml-names/ ,
both
<root xmlns="...">
and
<root xmlns:ns="...">
are valid,
xpath->query() will fail with the first case.
Reproduce code:
---------------
<?php
$xml=<<<end
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<child />
</root>
end;
$doc=new DomDocument();
$doc->loadXML($xml);
$xpath=new DomXpath($doc);
$query='/root';
$result=$xpath->query($query);
echo $result->length;
Expected result:
----------------
string '1'
Actual result:
--------------
string '0'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39505&edit=1