Current Location: Home> Function Categories> xml_parser_free

xml_parser_free

Free XML parser
Name:xml_parser_free
Category:XML parser
Programming Language:php
One-line Description:Release the XML parser.

Definition and usage

The xml_parser_free() function is used to free up an XML parser.

Tip: To create an XML parser, use xml_parser_create() function.

Example

Create an XML parser, parse the XML document ( note.xml ), and then release the XML parser:

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

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

xml_set_character_data_handler ( $parser , "char" ) ;
$fp = fopen ( "note.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 ) ) ) ;
}

// Release the XML parser
xml_parser_free ( $parser ) ;
fclose ( $fp ) ;
?>

Run the instance

grammar

 xml_parser_free ( parser )
parameter describe
parser Required. Specifies the XML parser to be released.
Similar Functions
Popular Articles