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--EXPECT-- 52getDocNamespaces 53 54Backwards Compatibility: 55recursion: 56array(2) { 57 ["p"]=> 58 string(20) "http://example.org/p" 59 ["t"]=> 60 string(20) "http://example.org/t" 61} 62array(2) { 63 ["p"]=> 64 string(20) "http://example.org/p" 65 ["t"]=> 66 string(20) "http://example.org/t" 67} 68array(2) { 69 ["p"]=> 70 string(20) "http://example.org/p" 71 ["t"]=> 72 string(20) "http://example.org/t" 73} 74 75non recursive: 76array(1) { 77 ["p"]=> 78 string(20) "http://example.org/p" 79} 80array(1) { 81 ["p"]=> 82 string(20) "http://example.org/p" 83} 84array(1) { 85 ["p"]=> 86 string(20) "http://example.org/p" 87} 88 89 90Using new 'from_root' bool set to false: 91recursion: 92array(2) { 93 ["p"]=> 94 string(20) "http://example.org/p" 95 ["t"]=> 96 string(20) "http://example.org/t" 97} 98array(1) { 99 ["t"]=> 100 string(20) "http://example.org/t" 101} 102array(0) { 103} 104 105non recursive: 106array(1) { 107 ["p"]=> 108 string(20) "http://example.org/p" 109} 110array(1) { 111 ["t"]=> 112 string(20) "http://example.org/t" 113} 114array(0) { 115} 116