Edit report at http://bugs.php.net/bug.php?id=53004&edit=1
ID: 53004 User updated by: php at oshahn dot de Reported by: php at oshahn dot de Summary: xml parser fails if newline befor the XML-Declaration Status: Bogus Type: Bug Package: *XML functions Operating System: Ubuntu 10.10 PHP Version: 5.3.3 Block user comment: N New Comment: I don't think so. http://www.w3.org/TR/xml/#sec-prolog-dtd A newline is not an element. Previous Comments: ------------------------------------------------------------------------ [2010-10-06 18:32:51] paj...@php.net Expected, that's part of the XML specifications. ------------------------------------------------------------------------ [2010-10-06 18:29:46] php at oshahn dot de Description: ------------ If there is a newline befor the XML-declaration, the parser fails. The w3.org only demand: "The document type declaration MUST appear before the first element in the document." Test script: --------------- <?php $data = '<?xml version="1.0"?><foo>bar</foo>'; function test($data) { print "try to parse: '" . htmlentities($data) . "'<br>\n"; $parser = xml_parser_create(); if (!xml_parse($parser, $data)) { print "Error: " . xml_error_string(xml_get_error_code($parser)) . "<br>"; print "Error in Line " . xml_get_current_line_number($parser) . " Column " . xml_get_current_column_number($parser) . "<hr>\n"; } else { print "works fine<hr>"; } } test($data); test("\n" . $data); Expected result: ---------------- I expect, that both test succeed. Actual result: -------------- Only the first test succeed, the second fails in Line 1 Column 21 "Reserved XML Name". ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53004&edit=1