ID:               41740
 User updated by:  dgrimes at scvl dot com
 Reported By:      dgrimes at scvl dot com
-Status:           Feedback
+Status:           Open
 Bug Type:         *XML functions
 Operating System: Compaq Tru64
 PHP Version:      5.2.3
 New Comment:

I loaded latest of both libxml2 (2.6.29) and libxslt (1.1.20) and I
still have the same problem. Should I be contacting the developers of
those libraries rather than you? If you're thinking the problem is with
libxml2 then perhaps the problem is not with PHP at all.

Thanks,
Dean


Previous Comments:
------------------------------------------------------------------------

[2007-06-20 09:26:25] [EMAIL PROTECTED]

Try updating libxml2. I cant reproduce this (testing with 2.6.26 and
higher).

------------------------------------------------------------------------

[2007-06-19 17:49:12] dgrimes at scvl dot com

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 this bug report at http://bugs.php.net/?id=41740&edit=1

Reply via email to