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$xml = <<<HERE 12<aw1:book xmlns:aw1="http://www.somewhere.com/namespace1" 13 xmlns:aw2="file:/DTD/somewhere.dtd"> 14<aw1:para>Any old text.</aw1:para> 15<aw2:td>An HTML table cell.</aw2:td> 16</aw1:book> 17HERE; 18 19$parser = xml_parser_create_ns(); 20xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); 21 22var_dump(xml_set_start_namespace_decl_handler( $parser, "Namespace_Start_Handler" )); 23var_dump(xml_set_end_namespace_decl_handler( $parser, "Namespace_End_Handler" )); 24 25xml_parse( $parser, $xml, true); 26xml_parser_free( $parser ); 27 28echo "Done\n"; 29 30function Namespace_Start_Handler( $parser, $prefix, $uri ) { 31 echo "Namespace_Start_Handler called\n"; 32 echo "...Prefix: ". $prefix . "\n"; 33 echo "...Uri: ". $uri . "\n"; 34} 35 36function Namespace_End_Handler($parser, $prefix) { 37 echo "Namespace_End_Handler called\n"; 38 echo "...Prefix: ". $prefix . "\n\n"; 39} 40 41function DefaultHandler( $parser, $data ) { 42 print( 'DefaultHandler Called<br/>' ); 43} 44?> 45--EXPECT-- 46bool(true) 47bool(true) 48Namespace_Start_Handler called 49...Prefix: aw1 50...Uri: http://www.somewhere.com/namespace1 51Namespace_Start_Handler called 52...Prefix: aw2 53...Uri: file:/DTD/somewhere.dtd 54Done 55