xml_set_object($this->xml_parser, $this). I specify the class property where the xml parser is stored in the first argument, then in the second argument I specify the address of the instantiated PHP object. This let's the parser know that all the callback functions to be registered are actually methods of the class specified at that address. This is like a 'pass by reference' in c or c++ or some call it simply 'referencing a variable'.
xml_parser_set_option(). Case folding just lets the parser know that I am not concerned about case-sensitivity when I parse my XML document but you could leave it unset if you wanted to define two different tags using case sensitivity i.e. <story> or <story>. Using the function
xml_set_element_handler()I specify the callback functions that I will be using for start and end tags, namely "startElement" and "endElement".
xml_set_character_data_handler()to specify the character data handler callback function named
characterData(). The remarked out function call,
xml_set_processing_instruction_handler(), is the call I would use to register the function
PIHandler()to deal with php code that may be included in the XML document. The remaining code just simply reads the XML file and parses it. If an error occurrs then the details are returned along with the line number that the error occured on.