Handling SAX Events
Let’s move on to a more focused discussion of the various event handlers you can register with the parser.
PHP includes handlers for elements and attributes, character data, processing instructions, external entities, and notations. Each of these is discussed in detail in the following sections.
The xml_set_element_handler() function is used to identify the functions that handle elements encountered by the XML parser as it progresses through a document. This function accepts three arguments: the handle for the XML parser, the name of the function to call when it finds an opening tag, and the name of the function to call when it finds a closing tag, respectively.
Here’s an example: