#34707 [WFx]: Cannot reuse XML parser, get "junk after document element" error message

From: Date: Mon, 03 Oct 2005 07:07:12 +0000
Subject: #34707 [WFx]: Cannot reuse XML parser, get "junk after document element" error message
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-85914@lists.php.net to get a copy of this message
ID: 34707 User updated by: apc at hotmail dot kg Reported By: apc at hotmail dot kg Status: Wont fix Bug Type: XML related Operating System: Windows XP Pro SP2 PHP Version: 4.4.0 New Comment: It's very bad for performance - creating new parser takes long time relatively to parse time... So if I have to do 10 parses I'll spend 0.05 sec creating parsers and only 0.001 sec in actual parsing. Also - for what I have ability to create and destroy parsers without reusing created?.. And, at last - no single note about "You cannot use parser twice!" Previous Comments: ------------------------------------------------------------------------ [2005-10-03 08:46:30] chregu@php.net Simply, you can't use the same parser twice... Just make a new one for the second parsing. ------------------------------------------------------------------------ [2005-10-02 16:58:43] apc at hotmail dot kg Description: ------------ When I try to parse XML into struct twice using the same parser - second attempt fails. Reproduce code: --------------- <?php $t=('../test/eg_snews.xml'); // any XML file $XMLContent = file_get_contents($t); $th = xml_parser_create(); echo "<hr>"; var_dump(xml_parse_into_struct ($th, $XMLContent, $V)); ; echo "<br>Result size: ".sizeof($V); echo "<br>Error code: ".$ec=xml_get_error_code($th); echo "<br>Error text: ".xml_error_string($ec); echo "<hr>"; var_dump(xml_parse_into_struct ($th, $XMLContent, $V)); ; echo "<br>Result size: ".sizeof($V); echo "<br>Error code: ".$ec=xml_get_error_code($th); echo "<br>Error text: ".xml_error_string($ec); ?> Expected result: ---------------- int(1) Result size: 301 Error code: 0 Error text: int(1) Result size: 301 Error code: 0 Error text: Actual result: -------------- int(1) Result size: 301 Error code: 0 Error text: int(0) Result size: 0 Error code: 9 Error text: junk after document element ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34707&edit=1

« previous php.bugs (#85914) next »