Annotation of embedaddon/php/ext/simplexml/tests/bug41861.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #41861 (getNamespaces() returns the namespaces of a node's siblings)
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded("simplexml")) print "skip"; ?>
! 5: --FILE--
! 6: <?php
! 7:
! 8: $xml = simplexml_load_string('<root>
! 9: <first_node_no_ns />
! 10: <ns1:node1 xmlns:ns1="#ns1" />
! 11: <ns2:node2 xmlns:ns2="#ns2" />
! 12: <ns3:node3 xmlns:ns3="#ns3" />
! 13: <last_node_no_ns />
! 14: </root>');
! 15:
! 16: $name = $xml->getName();
! 17: $namespaces = $xml->getNamespaces(True);
! 18: echo "root(recursive): '$name' -- namespaces: ", implode(', ', $namespaces), "\n";
! 19: $namespaces = $xml->getNamespaces(False);
! 20: echo "root(non-recursive): '$name' -- namespaces: ", implode(', ', $namespaces), "\n";
! 21:
! 22: foreach (array(null, '#ns1', '#ns2', '#ns3') as $ns)
! 23: {
! 24: foreach ($xml->children($ns) as $child)
! 25: {
! 26: $name = $child->getName();
! 27: $namespaces = $child->getNamespaces(false);
! 28:
! 29: echo "children($ns): '$name' -- namespaces: ", implode(', ', $namespaces), "\n";
! 30: }
! 31: }
! 32: ?>
! 33: ===DONE===
! 34: --EXPECT--
! 35: root(recursive): 'root' -- namespaces: #ns1, #ns2, #ns3
! 36: root(non-recursive): 'root' -- namespaces:
! 37: children(): 'first_node_no_ns' -- namespaces:
! 38: children(): 'last_node_no_ns' -- namespaces:
! 39: children(#ns1): 'node1' -- namespaces: #ns1
! 40: children(#ns2): 'node2' -- namespaces: #ns2
! 41: children(#ns3): 'node3' -- namespaces: #ns3
! 42: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>