1--TEST-- 2Test xml_set_start_namespace_decl_handler function: basic 3--SKIPIF-- 4<?php 5if (!extension_loaded("xml")) { 6 print "skip - XML extension not loaded"; 7} 8?> 9--FILE-- 10<?php 11/* Prototype : bool xml_set_start_namespace_decl_handler ( resource $parser , callback $handler ) 12 * Description: Set up start namespace declaration handler. 13 * Source code: ext/xml/xml.c 14 * Alias to functions: 15 */ 16 17$xml = <<<HERE 18<aw1:book xmlns:aw1="http://www.somewhere.com/namespace1" 19 xmlns:aw2="file:/DTD/somewhere.dtd"> 20<aw1:para>Any old text.</aw1:para> 21<aw2:td>An HTML table cell.</aw2:td> 22</aw1:book> 23HERE; 24 25$parser = xml_parser_create_ns(); 26xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); 27 28var_dump(xml_set_start_namespace_decl_handler( $parser, "Namespace_Start_Handler" )); 29var_dump(xml_set_end_namespace_decl_handler( $parser, "Namespace_End_Handler" )); 30 31xml_parse( $parser, $xml, true); 32xml_parser_free( $parser ); 33 34echo "Done\n"; 35 36function Namespace_Start_Handler( $parser, $prefix, $uri ) { 37 echo "Namespace_Start_Handler called\n"; 38 echo "...Prefix: ". $prefix . "\n"; 39 echo "...Uri: ". $uri . "\n"; 40} 41 42function Namespace_End_Handler($parser, $prefix) { 43 echo "Namespace_End_Handler called\n"; 44 echo "...Prefix: ". $prefix . "\n\n"; 45} 46 47function DefaultHandler( $parser, $data ) { 48 print( 'DefaultHandler Called<br/>' ); 49} 50?> 51--EXPECT-- 52bool(true) 53bool(true) 54Namespace_Start_Handler called 55...Prefix: aw1 56...Uri: http://www.somewhere.com/namespace1 57Namespace_Start_Handler called 58...Prefix: aw2 59...Uri: file:/DTD/somewhere.dtd 60Done 61