Handling Errors

During the initial stages of application development, it’s possible to get by without using error handlers in your code; however, as an application is being packaged for release, graceful error handling and recovery becomes a must.

PHP allows developers to accomplish this error handling via its xml_get_error_code() function (which prints the error code returned by the parser when it hits a bump) and its xml_error_string() function, (which returns a short, human-readable error message corresponding to the error code). Table 2.2 is a list of error codes and their corresponding named constants, together with what they mean.

Table 2.2. SAX Parser Error Codes
Error Code Error Constant Meaning
1 XML_ERROR_NO_MEMORY Parser out of memory ...

Get XML and PHP 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.