xml_get_error_code

int xml_get_error_code(resource parserID) 

Gets the error code for the specified parser.

Returns:

Error code on success; FALSE on error

Description:

Returns 0 if no error is available for the specified parser. This function is useful in conjunction with xml_error_string() to print the errors as the XML is being parsed.

Version:

PHP 3 >= 3.0.6, PHP 4 >= 4.0b1

Example:

Get error code on a parse error
 // an invalid XML document $xmlfile = 'myxmlfile.xml'; $xmlparser = xml_parser_create(); // open a file and read data from it for parsing $fp = fopen($xmlfile, 'r'); while ($xmldata = fread($fp, 4096)) { // parse the data chunk if (!xml_parse($xmlparser, $xmldata, feof($fp))) { // if parsing fails print the error description and ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.