|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58371 XMLReader cann't hide error while incorrect xml provided.
Submitted: 2008-10-08 06:52 UTC Modified: 2008-11-11 05:45 UTC
From: nodkz at mail dot ru Assigned:
Status: Not a bug Package: xmlReader (PECL)
PHP Version: 5.2.7RC2 OS: WinXP
Private report: No CVE-ID: None
 [2008-10-08 06:52 UTC] nodkz at mail dot ru
$myArray = readXml($data);
echo "Ok, go on working!!!";  // <-- But it would not

function readXml($data) {
	$reader=new XMLReader();
		return null;

	while($reader->read()) {  // <---  ERROR HERE!!!!   (XMLReader::read(): An Error Occured while reading)
		if($reader->nodeType == 1) {
				//return xmlToAssocArray($reader); // Pass XmlReader to array converter.

Expected result:
I want that script go on working, with hiding of parsing errors (see $data it contain incorrect xml document).

And I cant find any solution to obtain this result.

Actual result:
Scrip terminates and show this error ((((

XMLReader::read(): file:///D:/WWW/ksystem/debug/:1: parser error : Document is empty 
	[D:\WWW\ksystem\debug\index.php, line: 45]


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-21 12:31 UTC]
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PECL.

outside of the PHP warning that is issued, this is not reproducible in latest release.
 [2008-10-27 07:18 UTC] nodkz at mail dot ru
Same problem.

XMLReader can not hide errors.
 [2008-11-11 05:45 UTC]
The "Error Occurred" warning is expected and has nothing to 
do with the libxml errors. It is a PHP warning that there 
was a problem with the read() method. You need to either 
handle or suppress the warning.

Expected output:

Warning: XMLReader::read(): An Error Occured while reading 
in test.php on line 14
Ok, go on working!!!
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Sep 28 02:01:24 2023 UTC