Bug #1212: XML-Parser (Attributes) behave non-deterministic

From: Date: Mon, 08 Mar 1999 11:52:59 +0000
Subject: Bug #1212: XML-Parser (Attributes) behave non-deterministic
Groups: php.dev 
Request: Send a blank email to php-dev+get-4525@lists.php.net to get a copy of this message
From: cbi@cebis.net Operating system: Linux 2.0.36 PHP version: 3.0.7 PHP Bug Type: Misbehaving function Bug description: XML-Parser (Attributes) behave non-deterministic How to reproduce the problem: --- PHP script starts here --- <? $file = "data.xml"; function startElement($parser, $name, $attrs) { if ($name=="PRODUKT") { print "Produkt-ID ".$attrs["ID"]."<BR>"; } } 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); ?> --- end of script --- --- XML data file --- <?xml version="1.0" standalone="yes"?> <import> <produkt id="100"> <text>iMac</text> </produkt> <produkt id="101"> <text>IBM</text> </produkt> <produkt id="102"> <text>Yakumo</text> </produkt> <produkt id="103"> <text>IIyama</text> </produkt> <produkt id="104"> <text>Microsoft</text> </produkt> <produkt id="105"> <text>Noname</text> </produkt> <produkt id="106"> <text>test</text> </produkt> <produkt id="107"> <text>gaudi</text> </produkt> <produkt id="108"> <text>icat sucks</text> </produkt> </import> ---end of XML--- now run the script on the xml-file, the output looks like this --- sample output 1 --- Produkt-ID 100 Produkt-ID 101 Produkt-ID 102 Produkt-ID 103 Produkt-ID 104 Produkt-ID 105 Produkt-ID 106 Produkt-ID 107 Produkt-ID 108 --- end ------------ now reload the page a couple of times, I sometimes get -- sample output 2 --- Produkt-ID 100P Produkt-ID 101P Produkt-ID 102P Produkt-ID 103P Produkt-ID 104P Produkt-ID 105P Produkt-ID 106P Produkt-ID 107P Produkt-ID 108P --- end ---- That means some random characters are appended to the content of $attrs["ID"] My PHP-Configuration ./configure --with-xml --with-gd=../gd1.3 --with-sybase-ct --enable-track-vars --with-apache=../apache_1.3.4 Expat Version 1.0.2 -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#4525) next »