PHP Function xml_Set_Object
PHP's expat XML parser lets you set functions that it calls when it encounters different parts of an XML file, such as opening and closing element tags or character data (the text between the tags). This is known as event-based parsing and contrasts with tree-based DOM XML parsing. PHP supports two interfaces to expat: a procedural one and an object-oriented one. The object-oriented one lets you bind an object to the parser and use that object's methods instead of global ones. The pc_RSS_parser class is an example of this type of parser.
The xml_set_object() function allows you to set the object on which an XML parser should apply a handler function. It takes three arguments: a reference to the XML parser, the handler function, and the object to which the parser should apply the function.
As the XML parser passes through each element in the XML file, it applies the handler function to that element. For example, the pc_RSS_parser instance binds to an object and applies the start_element() function to that object when the XML parser reaches the tag with the
When the XML parser is finished processing the XML file, it closes the pc_RSS_parser object and cleans up any open parsers. Passing the pc_RSS_parser reference as a call-time ref like this, however, causes PHP to complain that it can't find the handler functions, even though you specified them correctly. This can be fixed by calling xml_parser_free() when the parsing is finished.