xml parser class? Urgent!!
Posted: Wed Jul 30, 2003 8:59 pm
Dear php fellows
I'm trying to create a xml parser class with the following functions but I get errors saying "unable to call handler startElement()" and "unable to call handler endElement()" and "unable to call handler characterData()".
I've been working on this for ages and can't figure out why so could anyone show some light on this? I need to be able to "see" the data coming in from characterData in the endElement too. An xml string is sent to the constructor.
class xmlread {
function xmlread22($str) {
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler ($xml_parser, "characterData");
xml_parse($xml_parser, $str);
xml_parser_free($xml_parser);
}
function startElement($parser, $name, $attrs) {
global $ctag;
$this->ctag = $name;
}
function endElement($parser, $name) {
do something;
}
}
I'm trying to create a xml parser class with the following functions but I get errors saying "unable to call handler startElement()" and "unable to call handler endElement()" and "unable to call handler characterData()".
I've been working on this for ages and can't figure out why so could anyone show some light on this? I need to be able to "see" the data coming in from characterData in the endElement too. An xml string is sent to the constructor.
class xmlread {
function xmlread22($str) {
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler ($xml_parser, "characterData");
xml_parse($xml_parser, $str);
xml_parser_free($xml_parser);
}
function startElement($parser, $name, $attrs) {
global $ctag;
$this->ctag = $name;
}
function endElement($parser, $name) {
do something;
}
}