note 17794 added to function.xml-parse

From: Date: Tue, 25 Dec 2001 09:45:13 +0000
Subject: note 17794 added to function.xml-parse
Groups: php.notes 
Request: Send a blank email to php-notes+get-23827@lists.php.net to get a copy of this message
the optional parameter confused me for a while. I had parsed my file using: 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))); } but recieved a missing element error if I called it repeatedly. That makes perfect sense when I think about it, the purpose of the parameter is to tell the parser that this is the last chunk of data in the current parse. Since I had to call the parser repeatedly I used: while($data = fread($fp, 4096)) @xml_parse($parser, $data); Which works fine. If you are using a parser repeatedly (or recurcsively) this should do the trick. -- http://www.php.net/manual/en/function.xml-parse.php http://master.php.net/manage/user-notes.php?action=edit+17794 http://master.php.net/manage/user-notes.php?action=delete+17794 http://master.php.net/manage/user-notes.php?action=reject+17794

« previous php.notes (#23827) next »