PHP 4.0 Bug #6500 Updated: XML - startElementHandler
| From: | Bug Database | Date: | Wed, 06 Sep 2000 17:12:55 +0000 |
| Subject: | PHP 4.0 Bug #6500 Updated: XML - startElementHandler | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-32416@lists.php.net to get a copy of this message | ||
ID: 6500
Updated by: stas
Reported By: mario.staas@free-e-project.org
Status: Open
Bug Type: *XML functions
Assigned To:
Comments:
Previous Comments:
[2000-09-03 06:07:17] stas@php.net
1. Don't use &$this syntax. It is decprecated
2. Could you cut down your script as much as possible and post it and the minimal XML reproducing
buggy behaviour?
---------------------------------------------------------------------------
[2000-09-03 05:58:25] mario.staas@free-e-project.org
Sorry! But the error still exists!
I know the (first) bug in PHP4.0.2 (warnings -> function of startElementHandler not found ....)
and it´s fixed.
The bug I described is a little different. It is not the "startElementHandler" itself.
1. CONSTRUCTOR
function XML_HANDLER() {
$this->O_XML_PARSER = xml_parser_create();
xml_set_object($this->O_XML_PARSER,&$this);
xml_set_element_handler($this->O_XML_PARSER,"Tag_Start","Tag_End");
xml_set_character_data_handler($this->O_XML_PARSER,"CData");
}
2. Parse from file (function)
... some statements
while($L_LINE = fread($L_FP, 4096)) {
$this->O_LINE++;
if(!xml_parse($this->O_XML_PARSER, $L_LINE, feof($L_FP)))
die(sprintf("XML error: %s at line %d in file %s",
xml_error_string(xml_get_error_code($this->O_XML_PARSER)),
xml_get_current_line_number($this->O_XML_PARSER), $A_FILE));
}
fclose($L_FP);
----> var_dump($this->O_DATA);
------------OUTPUT------------> array(0) ----> ERROR!!!!!!!!!!!
3. Tag_Start function
function Tag_Start($A_PARSER, $A_ELE_NAME, $A_ATTRIBS) {
if (!isset($A_ATTRIBS)) return;
while(list($L_KEY, $L_VALUE) = each($A_ATTRIBS)) {
$L_EVAL = $this->O_EVAL .'["ATTRIBUTE"]'
.'["' .strtoupper($L_KEY) .'"]';
eval("$this->O_DATA$L_EVAL = $L_VALUE;");
}
----> var_dump($this->O_DATA);
-----------OUTPUT-----------> array(1) { ["FEP_VARS"]=> array(1) {
["STAT"]=> array(1) { ["TORPEDO"]=> array(1) {
["ATTRIBUTE"]=> array(2) { ["VERSION"]=> string(5) "V0300"
["DATE"]=> int(20000701) } } } } } ----> OK !!!!!!!!!!!
}
This is a very critical bug! Please check it...
---------------------------------------------------------------------------
[2000-09-02 22:43:41] sniper@php.net
Please try latest CVS or snapshot from http://snaps.php.net as
this should be
fixed 2 days ago. Reopen this bug report if problem still exists.
--Jani
---------------------------------------------------------------------------
[2000-09-02 05:05:24] mario.staas@free-e-project.org
I use a class to handle XML-files. After the installation of version 4.0.2 (up to CVS-version
200009020045) I have problems with the XML functions.
In the "startElementHandler" function I move the attribs into a variable ($this->DATA).
A var_dump inside the "startElementHandler" shows the correct image of the XML attribs.
But after parsing a XML-file (outside xml_set_element_handler or xml_set_character_data_handler) a
var_dump($this->DATA) shows the following resault:
array(0)
In PHP beta, PHP4.0.0 and PHP4.0.1 I had no problems.
I use a default php.ini file (without ZendOptimizer).
Modules: default + mysql, zlib
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=6500