1--TEST-- 2Bug #55218 getDocNamespaces from current element and not root 3--SKIPIF-- 4<?php 5if (!extension_loaded("simplexml")) print "skip SimpleXML not present"; 6if (!extension_loaded("libxml")) print "skip LibXML not present"; 7?> 8--FILE-- 9<?php 10 11$x = new SimpleXMLElement( 12'<?xml version="1.0" standalone="yes"?> 13<people xmlns:p="http://example.org/p" > 14 <person id="1" xmlns:t="http://example.org/t" > 15 <t:name>John Doe</t:name> 16 </person> 17 <person id="2">Susie Q. Public</person> 18 <o> 19 <p:div>jdslkfjsldk jskdfjsmlkjfkldjkjflskj kljfslkjf sldk</p:div> 20 </o> 21</people>'); 22 23echo "getDocNamespaces\n"; 24echo "\nBackwards Compatibility:\n"; 25echo "recursion:\n"; 26 27var_dump ( $x->getDocNamespaces(true) ) ; 28var_dump( $x->person[0]->getDocNamespaces(true) ); 29var_dump( $x->person[1]->getDocNamespaces(true) ); 30 31echo "\nnon recursive:\n"; 32 33var_dump( $x->getDocNamespaces(false) ); 34var_dump( $x->person[0]->getDocNamespaces(false) ); 35var_dump( $x->person[1]->getDocNamespaces(false) ); 36 37echo "\n\nUsing new 'from_root' bool set to false:\n"; 38echo "recursion:\n"; 39 40var_dump ( $x->getDocNamespaces(true, false) ) ; 41var_dump( $x->person[0]->getDocNamespaces(true, false) ); 42var_dump( $x->person[1]->getDocNamespaces(true, false) ); 43 44echo "\nnon recursive:\n"; 45 46var_dump( $x->getDocNamespaces(false, false) ); 47var_dump( $x->person[0]->getDocNamespaces(false, false) ); 48var_dump( $x->person[1]->getDocNamespaces(false, false) ); 49 50?> 51===DONE=== 52--EXPECTF-- 53getDocNamespaces 54 55Backwards Compatibility: 56recursion: 57array(2) { 58 ["p"]=> 59 string(20) "http://example.org/p" 60 ["t"]=> 61 string(20) "http://example.org/t" 62} 63array(2) { 64 ["p"]=> 65 string(20) "http://example.org/p" 66 ["t"]=> 67 string(20) "http://example.org/t" 68} 69array(2) { 70 ["p"]=> 71 string(20) "http://example.org/p" 72 ["t"]=> 73 string(20) "http://example.org/t" 74} 75 76non recursive: 77array(1) { 78 ["p"]=> 79 string(20) "http://example.org/p" 80} 81array(1) { 82 ["p"]=> 83 string(20) "http://example.org/p" 84} 85array(1) { 86 ["p"]=> 87 string(20) "http://example.org/p" 88} 89 90 91Using new 'from_root' bool set to false: 92recursion: 93array(2) { 94 ["p"]=> 95 string(20) "http://example.org/p" 96 ["t"]=> 97 string(20) "http://example.org/t" 98} 99array(1) { 100 ["t"]=> 101 string(20) "http://example.org/t" 102} 103array(0) { 104} 105 106non recursive: 107array(1) { 108 ["p"]=> 109 string(20) "http://example.org/p" 110} 111array(1) { 112 ["t"]=> 113 string(20) "http://example.org/t" 114} 115array(0) { 116} 117===DONE===