#41740 [NEW]: XML Declaration Error

From: Date: Tue, 19 Jun 2007 17:49:12 +0000
Subject: #41740 [NEW]: XML Declaration Error
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-113933@lists.php.net to get a copy of this message
From: dgrimes at scvl dot com Operating system: Compaq Tru64 PHP version: 5.2.3 PHP Bug Type: *XML functions Bug description: XML Declaration Error Description: ------------ I'm getting the following error: XML error: XML declaration not finished at line 1 Here is the xml code: <?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> However, if I remove line one completely the code works but I can't have any reference to <?xml .... ?>. Reproduce code: --------------- I took this code from the php.net xml examples. Everyghing works OK in php4 but not php5. Here is the test program: <?php $file = "test.xml"; $depth = array(); function startElement($parser, $name, $attrs) { global $depth; for ($i = 0; $i < $depth[$parser]; $i++) { echo " "; } echo "$name\n"; $depth[$parser]++; } function endElement($parser, $name) { global $depth; $depth[$parser]--; } $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: ---------------- NOTE TO FROM HEADING BODY This was run with the above code without the <?xml ... ?> line. Actual result: -------------- XML error: XML declaration not finished at line 1 Run with the same code with the <?xml ... ?> line. -- Edit bug report at http://bugs.php.net/?id=41740&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41740&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41740&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41740&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41740&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41740&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41740&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41740&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41740&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41740&r=support Expected behavior: http://bugs.php.net/fix.php?id=41740&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41740&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41740&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41740&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41740&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41740&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41740&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41740&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41740&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41740&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41740&r=mysqlcfg

« previous php.bugs (#113933) next »