xml_get_error_code
Get XML parser error code
xml_get_error_code()
function returns the error code of the XML parser.
When an error occurs, return the error code, 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_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 : 76 Line : 5 Column : 41
xml_get_error_code ( parser )
parameter | describe |
---|---|
parser | Required. Specifies the XML parser to use. |