#42026 [Opn->Fbk]: Incorrect handling of default namespaces
| From: | jani@php.net | Date: | Wed, 18 Jul 2007 11:12:27 +0000 |
| Subject: | #42026 [Opn->Fbk]: Incorrect handling of default namespaces | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-115172@lists.php.net to get a copy of this message | ||
ID: 42026
Updated by: jani@php.net
Reported By: mail_ben_schmidt at yahoo dot com dot au
-Status: Open
+Status: Feedback
Bug Type: SimpleXML related
Operating System: Mac OS X
PHP Version: 5.2.3
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
Some fixes were already done regarding namespaces.
Previous Comments:
------------------------------------------------------------------------
[2007-07-18 11:12:22] mail_ben_schmidt at yahoo dot com dot au
Irrelevant to the bug itself, but one of my numbers that were meant to
be helpful in the code example was wrong. Should have read:
<other:elem attr="abc"/>1
<other:elem ns:attr="abc"/>0
<other:elem other:attr="abc"/>1
------------------------------------------------------------------------
[2007-07-18 11:09:01] mail_ben_schmidt at yahoo dot com dot au
Description:
------------
When getting children/attributes without using methods to specify a
namespace explicity, non-prefixed names are returned, but not prefixed
ones, even if the prefixed names are in the same namespace.
(Note that in fixing this bug there is a subtlety: the default
namespace for attributes is inherited from the element in which they
appear.)
Reproduce code:
---------------
$str=<<<DONE
<?xml version="1.0" encoding="utf-8"?>
<root
xmlns="http://localhost/a"
xmlns:ns="http://localhost/a"
xmlns:other="http://localhost/b"
>
<elem attr="abc"/>1
<elem ns:attr="abc"/>1
<elem other:attr="abc"/>0
<ns:elem attr="abc"/>1
<ns:elem ns:attr="abc"/>1
<ns:elem other:attr="abc"/>0
<other:elem attr="abc"/>0
<other:elem ns:attr="abc"/>0
<other:elem other:attr="abc"/>1
</root>
DONE;
$xml = simplexml_load_string($str);
foreach ($xml->elem as $elem) {
echo count($elem->attributes());
}
echo "\n";
foreach ($xml->children('http://localhost/a')->elem as $elem) {
echo count($elem->attributes());
}
echo "\n";
foreach ($xml->children('http://localhost/b')->elem as $elem) {
echo count($elem->attributes());
}
echo "\n";
Expected result:
----------------
110110 110110 101
Actual result:
--------------
100 100100 100
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42026&edit=1