Current Location: Home> Function Categories> xml_get_current_line_number

xml_get_current_line_number

Get the current line number of the XML parser
Name:xml_get_current_line_number
Category:XML parser
Programming Language:php
One-line Description:Returns the current line number from the XML parser.

Definition and usage

xml_get_current_line_number() function returns the current line number of the XML parser.

Example

When an error occurs, return the error description, line number, and column number of the XML parser:

 <?php
// Invalid XML file
$xmlfile = 'test.xml' ;
$xmlparser = xml_parser_create ( ) ;

// Open the file and read the data
$fp = fopen ( $xmlfile , 'r' ) ;
while ( $xmldata = fread ( $fp , 4096 ) ) {
  // Analyze data blocks
  if ( ! xml_parse ( $xmlparser , $xmldata , feof ( $fp ) ) ) {
    die ( print "ERROR: "
    . xml_error_string ( xml_get_error_code ( $xmlparser ) )
    . "<br>Line: "
    . xml_get_current_line_number ( $xmlparser )
    . "<br>Column: "
    . xml_get_current_column_number ( $xmlparser )
    . "<br>" ) ;
  }
}
xml_parser_free ( $xmlparser ) ;
?>

The output of the above code may be:

 ERROR : Mismatched tag
Line : 5
Column : 41

grammar

 xml_get_current_line_number ( parser )
parameter describe
parser Required. Specifies the XML parser to use.
Similar Functions
Popular Articles