The xml_set_default_handler() function sets the default data handler for the XML parser.
This function specifies what function to be called whenever the parser finds data in the XML file.
This function returns TRUE on success, or FALSE on failure.
Parameter | Description |
---|---|
parser | Required. Specifies XML parser to use |
handler | Required. Specifies a function to be used as an event handler |
The Function specified by the "handler" parameter must have two
parameters:
Parameter | Description |
---|---|
parser | Required. Specifies a variable containing the XML parser calling the handler |
data | Required. Specifies a variable containing the data from the XML file as a string |
Note: The data_handler parameter can also be an array containing an object reference and a method name.
XML File
PHP Code
The output of the code above will be:
If you select "View source" in the browser window, you will see the following HTML: