hi peeps,
got the following problem:
i got a class to parse a xml file, its basically the code from tutorial ‘parsing xml intermediate’.
now in the constructor, where you set the element handlers and the data handler, my question: how do you adress the functions (e.g. startTag) in the class?
because every time the class is trying to parse it will fail because it cant find the functions.
...
// Constructor
function PhotoAlbum($xml_file) {
// Set xml file to parse
$this.$xml_file = $xml_file;
$xml_parser = xml_parser_create();
// Sets the element handlers for the start and end tags
xml_set_element_handler($xml_parser, "$this->startTag", "$this->endTag");
// Sets the data handler, same as before...
xml_set_character_data_handler($xml_parser, "$this->contents");
// Opens the file or gives an error message
$fp = fopen($xml_file, "r") or die("Could not open file");
// Reads the file or gives an error message
$data = fread($fp, filesize($xml_file)) or die("Could not read file");
if(!(xml_parse($xml_parser, $data, feof($fp)))){
die("Error on line " . xml_get_current_line_number($xml_parser));
}
// Free up memory
xml_parser_free($xml_parser);
// Close the file
fclose($fp);
}
// XML HANDLERS
var $current_tag;
function startTag($parser, $data){
// global $current_tag;
$current_tag .= "*$data";
}
...
need help quickly. thx in advance