Current Location: Home> Function Categories> xml_set_notation_decl_handler

xml_set_notation_decl_handler

Setting up notation declaration handler
Name:xml_set_notation_decl_handler
Category:XML parser
Programming Language:php
One-line Description:Set up symbolic declaration handlers for the XML parser.

Definition and usage

xml_set_notation_decl_handler() function is used to specify the function to be called when the parser finds a symbolic declaration in an XML document.

Note: The handler parameter can also be an array containing object references and method names.

Example

Create an XML parser, set up a character data handler, set up a symbol declaration handler, and parse XML documents:

 <?php
// Create XML parser
$parser = xml_parser_create ( ) ;

function char ( $parser , $data ) {
  echo $data ;
}

function not_decl_handler ( $parser , $not , $base , $sysID , $pubID ) {
  echo " $not <br>" ;
  echo " $sysID <br>" ;
  echo " $pubID <br>" ;
}

// Set character data processing program
xml_set_character_data_handler ( $parser , "char" ) ;

// Set symbol declaration handler
xml_set_notation_decl_handler ( $parser , "not_decl_handler" ) ;

$fp = fopen ( "note_notation.xml" , "r" ) ;

while ( $data = fread ( $fp , 4096 ) ) {
  // parse XML data
  xml_parse ( $parser , $data , feof ( $fp ) ) or
  die ( sprintf ( "XML error: %s on line %d" ,
  xml_error_string ( xml_get_error_code ( $parser ) ) ,
  xml_get_current_line_number ( $parser ) ) ) ;
}

xml_parser_free ( $parser ) ;
fclose ( $fp ) ;
?>

grammar

 xml_set_notation_decl_handler ( parser , handler )
parameter describe
parser Required. Specify the XML parser to use
Handler

Required. Specifies the function used as the event handler. This function must accept five parameters:

  • $parser - Variable containing the XML parser that calls the handler
  • $name - Variable containing symbolic names
  • $base - The basis for parsing the system identifier (system_id) of an external entity. Currently, this is always an empty string
  • $system_id - System identifier for external symbol declaration
  • $public_id - Public identifier for external symbol declaration
Similar Functions
Popular Articles