ID: 39365
User updated by: z_rules55 at hotmail dot com
Reported By: z_rules55 at hotmail dot com
-Status: Bogus
+Status: Open
Bug Type: DOM XML related
Operating System: WinXP Professional
PHP Version: 5.2.0
New Comment:
Per the XML spec, setting the xmlns attribute on an element but with no
prefix (like I did with $root) sets a default namespace for that element
and its descendants. $default_ns_element and $explicit_ns_element,
therefore, do not need the xmlns attribute to be in 'my_namespace'
because they inherit the namespace from $root by default.
Previous Comments:
------------------------------------------------------------------------
[2006-11-04 08:03:04] [EMAIL PROTECTED]
$xml->createElement('element', 'default_ns_element')
That's not in the default namespace, that's in no namespace at
all this way.
Can't work this way
------------------------------------------------------------------------
[2006-11-03 21:28:54] z_rules55 at hotmail dot com
Additional note: getElementsByTagName('element') does, in fact, find
both nodes.
------------------------------------------------------------------------
[2006-11-03 21:12:54] z_rules55 at hotmail dot com
Description:
------------
Calling getElementsByTagNameNS() on a DOMDocument or a DOMElement does
not return elements that are under a default namespace. The example
below finds $explicit_ns_element, but not $default_ns_element.
Reproduce code:
---------------
<?php
$xml = new DOMDocument();
$namespace = 'my_namespace';
$root = $xml->appendChild($xml->createElementNS($namespace, 'root'));
$default_ns_element = $root->appendChild($xml->createElement('element',
'default_ns_element'));
$explicit_ns_element =
$root->appendChild($xml->createElementNS($namespace, 'element',
'explicit_ns_element'));
foreach($xml->getElementsByTagNameNS($namespace, 'element') as $el) {
echo $el->nodeValue."\n";
}
echo "\n";
foreach($root->getElementsByTagNameNS($namespace, 'element') as $el) {
echo $el->nodeValue."\n";
}
?>
Expected result:
----------------
default_ns_element
explicit_ns_element
default_ns_element
explicit_ns_element
Actual result:
--------------
explicit_ns_element
explicit_ns_element
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39365&edit=1