|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-03-09 08:03 UTC] steffann
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 04:00:01 2025 UTC |
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