Dealing with XML errorsDealing with XML errors when loading documents is a very simple task. Using the libxml functionality it is possible to suppress all XML errors when loading the document and then iterate over the errors. The libXMLError object, returned by libxml_get_errors, contains several properties including the message, line and column (position) of the error.
Example #1 Loading broken XML string
The above example will output: Failed loading XML Blank needed here parsing XML declaration: '?>' expected Opening and ending tag mismatch: xml line 1 and broken Premature end of data in tag broken line 1 |