ID:               39365
 Updated by:       [EMAIL PROTECTED]
 Reported By:      z_rules55 at hotmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         DOM XML related
 Operating System: WinXP Professional
 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

You are mixing level 1 and level 2 functionality. Specs also indicate
that doing this will lead to unexpected behavior. Must use
createElementNS().


Previous Comments:
------------------------------------------------------------------------

[2006-11-04 14:26:26] z_rules55 at hotmail dot com

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.

------------------------------------------------------------------------

[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

Reply via email to