php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31589 xml_parse_into_struct won't parse data read from a file
Submitted: 2005-01-18 00:04 UTC Modified: 2005-01-27 17:12 UTC
From: fuddyq at gmail dot com Assigned:
Status: Closed Package: XML related
PHP Version: 5.0.2 OS: Windows2000
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fuddyq at gmail dot com
New email:
PHP Version: OS:

 

 [2005-01-18 00:04 UTC] fuddyq at gmail dot com
Description:
------------
When using the documentation for xml_parse_into_struct to test xml read from a file, the function appears to unsuccessfully parse the data.

The xml file is valid xml, is being read properly and can be dumped by it's fread variable $data.  I can copy and paste the xml into the $data variable and the function will work properly.

The xml_error_string(xml_get_error_code($parser)) is "Empty Document" which is incorrect.

Reproduce code:
---------------
$xml_file = 'someXMLfile.xml';
$filehandler = fopen($xml_file, 'r');
$data = fread($filehandler, filesize($xml_file));
fclose($filehandler);

$parser = xml_parser_create();
xml_parse_into_struct($parser, $data, $vals, $index);
xml_parser_free($parser);

echo "Index array\n";
print_r($index);
echo "\nVals array\n";
print_r($vals);

Expected result:
----------------
Similar results to the documentation for the xml_parse_into_struct() function via print_r().

Actual result:
--------------
Index array Array ( ) Vals array Array ( )

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-21 00:09 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.

I can't reproduce it. 
Make sure $data is not empty and error_reporting is set to E_ALL.
 [2005-01-27 17:12 UTC] fuddyq at gmail dot com
My apologies for the bug filing - I tried a different example on the function page for xml_parse_into_struct() and it seems to work now.

Confused.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC