Re: Strange XML/file read problem
| From: | Analysis & Solutions | Date: | Thu, 08 Aug 2002 11:48:56 +0000 |
| Subject: | Re: Strange XML/file read problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-111629@lists.php.net to get a copy of this message | ||
On Thu, Aug 08, 2002 at 03:57:04AM -0500, Matt Holmes wrote:
>
> $fp = fopen($XMLPath . $_REQUEST['system_template'] . ".xml",
> "r");
> if(!$fp)
> die('Could not read XML data file');
>
> while ($data = fread($fp, 4096))
> {
> xml_parse($parser, $data, feof($fp)) or
> die(sprintf("XML error: %s at line %d",
> xml_error_string(xml_get_error_code($parser)),
> xml_get_current_line_number($parser)));
> }
A stab in the dark... I'm used to sending a whole string to the parser in
one shot. Give that a try. Move the xml_parse() function below the while
loop. Accumulate the incoming data in a variable in the while loop...
$data = '';
while ($data .= fread($fp, 4096)) {
}
Then pass the whole $data string to the parser.
xml_parse($parser, $data)...
On die, you can have it spit out the whole $data to the screen so you can
look for errors in it.
--Dan
--
PHP classes that make web design easier
SQL Solution | Layout Solution | Form Solution
sqlsolution.info | layoutsolution.info | formsolution.info
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409