By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,947 Members | 1,594 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,947 IT Pros & Developers. It's quick & easy.

Namespace Handler isn't called

P: n/a
I'm using the XML functions in PHP 5. The callback function I set for
namespace declarations doesn't get called. Can anyone help me out?
The code is:
$xml = '<addressbook
xmlns:ab="http://www.somewhere.com/addressbook/">' .
'</addressbook>';
$parser = xml_parser_create_ns();

xml_set_element_handler( $parser, 'StartHandler', 'EndHandler' );

/* The handler doesn't get called for some reason */
xml_set_start_namespace_decl_handler( $parser, 'NSHandler' );

xml_parse( $parser, $xml, true);
xml_parser_free( $parser );
function StartHandler( $parser, $name, $attrs ) {
print( 'StartHandler Called<br/>' );
}
function EndHandler( $parser, $name ) {
print( 'EndHandler Called<br/>' );
}
function NSHandler( $parser, $prefix, $uri ) {
print( 'NSHandler Called<br/>' );
}
And the output is:

StartHandler Called
EndHandler Called
I want the output to be

StartHandler Called
EndHandler Called
NSHandler Called
Cheers,
Aeden
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.