#29657 [Opn->Csd]: xml_* functions throw non descriptive error, compared to php4
| From: | chregu@php.net | Date: | Thu, 19 Aug 2004 12:39:01 +0000 |
| Subject: | #29657 [Opn->Csd]: xml_* functions throw non descriptive error, compared to php4 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-64930@lists.php.net to get a copy of this message | ||
ID: 29657
Updated by: chregu@php.net
Reported By: black at scene-si dot org
-Status: Open
+Status: Closed
Bug Type: XML related
Operating System: debian
PHP Version: 5.0.0
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2004-08-14 10:52:59] chregu@php.net
libxml2 (used for ext/xml in PHP 5) has many many more
error messages than expat (in PHP 4) and is therefore
more descriptive about what really is wrong. But noone
bothered to really translate the messages into plain
english. I'm currently doing it for the more obvious
messages
But don't expect the same Error Message in PHP 4 and PHP
5, nor the same error numbers. As said, there are many
more error messages in libxml2.
------------------------------------------------------------------------
[2004-08-13 17:53:18] black at scene-si dot org
Description:
------------
when validating an incorrectly formated xml file, the errors from php
5.0.0 are vaguely descriptive, outputting some constant name and not a
human readable error message
Reproduce code:
---------------
#!/usr/bin/php5
<?php
if ($argc<2) {
echo "Usage: ".$PHP_SELF." file.xml\n";
exit;
}
$file = $argv[1];
$depth = array();
function startElement($parser, $name, $attrs) {}
function endElement($parser, $name) {}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
if (!($fp = fopen($file, "r"))) {
die("could not open XML input");
}
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
xml_parser_free($xml_parser);
Expected result:
----------------
XML error: mismatched tag at line 14
(from php4, identical code)
Actual result:
--------------
XML error: XML_ERR_TAG_NAME_MISMATCH at line 14
(php5 output)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29657&edit=1