php.net |  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nodkz at mail dot ru
New email:
PHP Version: OS:

 

 [2008-10-08 06:52 UTC] nodkz at mail dot ru
Description:
------------
$data="id=&bill%5Bcustomer_id%5D=1";
$myArray = readXml($data);
echo "Ok, go on working!!!";  // <-- But it would not


function readXml($data) {
	$reader=new XMLReader();
	libxml_use_internal_errors(true);
	
	if(!$reader->XML($data, 'UTF-8', LIBXML_NOERROR|LIBXML_ERR_NONE|LIBXML_NOWARNING)) {
		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]

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-21 12:31 UTC] rrichards@php.net
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 http://www.php.net/downloads.php

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] rrichards@php.net
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-2019 The PHP Group
All rights reserved.
Last updated: Mon Mar 25 20:01:26 2019 UTC