|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-01-13 07:13 UTC] lobbin@php.net
[2002-02-19 00:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 02:00:01 2025 UTC |
I am receiving "segmentation fault" when using xml_set_object() and setting handlers in the constructor. I moved them to the parse() method and the crashes stop. I found the resolution for a similiar issue in the feedback thread at the end of xml_set_object() documentation just in case you guys are already aware of this issue : ) Feedback Thread =============== williams@cse.unl.edu 06-Dec-2000 12:42 If xml_set_object is not called in the constructor of an object, the values that the parser modifies will be saved. Else, the values do not seem to be saved as stated by "i_sofer" above. --- Start Example Code --- class foo { var xmlparser; function foo() { \\the constructor $this->xmlparser=xmlparser_create(); } function parse() { xml_set_object($this->xmlparser,&$this); \\also include data handler \\and element handlers here } } --- End Example Code --- My Code ======= function parse($data) { $this->parser = xml_parser_create(); xml_set_object($this->parser,&$this); xml_set_element_handler($this->parser,"tag_open","tag_close"); xml_set_character_data_handler($this->parser,"cdata"); xml_set_processing_instruction_handler($this->parser,"tag_pi"); xml_parse($this->parser,$data); if (!xml_parse($this->parser, $data, 1)) { $error = sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->parser)), xml_get_current_line_number($this->parser)); echo $error; } // if xml_parser_free($this->parser); } // fn