PHP xml_set_default_handler() Function
Complete PHP XML Reference Manual
Definition and Usage
The xml_set_default_handler() function sets up a default data handler for an XML parser.
This function specifies the function to be called whenever the parser finds data in an XML file.
On success, this function returns TRUE. On failure, it returns FALSE.
Syntax
xml_set_default_handler(parser,handler)
| Parameters | Description |
|---|---|
| parser | Required. Specifies the XML parser to use. |
| handler | Required. Specifies the function to use as the event handler. |
The function specified by the "handler" parameter must have two parameters:
| Parameters | Description |
|---|---|
| parser | Required. Specifies a variable containing the XML parser that called the handler. |
| data | Required. Specifies a variable containing the data from the XML file (as a string). |
Tips and Notes
**Note:** The handler parameter can also be an array containing an object reference and a method name.
Example
XML file
PHP code
The output of the code above is shown below:
Tove Jani Reminder Don't forget me this weekend!
If you select "View Source" in the browser window, you will see the following HTML:
Complete PHP XML Reference Manual