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

History

No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".