|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-07-22 15:22 UTC] kenashkov at gmail dot com
[2008-03-26 19:48 UTC] rrichards@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 21:00:02 2025 UTC |
Description: ------------ When assigning multiple times to ane variable an object which contains a XML parser, there is a problem when the xml_parse is called. The parser can not call the registered handlers. The problem can be avoided if the variable is unset before the second call, or using $doc1 =& new xml_doc() for every assignment. Reproduce code: --------------- <? class xml_doc { function xml_doc() { $this->res = xml_parser_create_ns(); xml_set_object($this->res,$this); xml_set_element_handler($this->res,'start_element','end_element'); } function load_string($string) { xml_parse($this->res,$string); } function start_element() { } function end_element() { } } $str = '<?xml version="1" encoding="UTF-8" standalone="yes"?><root></root>'; $doc1 = new xml_doc(); $doc1->load_string($str); //unset($doc1);//this solves the problem //or using $doc1 =& new xml_doc(); in every assignment $doc1 = new xml_doc(); $doc1->load_string($str); ?> Expected result: ---------------- Nothing really... it is too simple to do real parsing. Actual result: -------------- Warning: xml_parse() [function.xml-parse.html]: Unable to call handler start_element() in file.php on line 13 Warning: xml_parse() [function.xml-parse.html]: Unable to call handler end_element() in file.php on line 13