PHP xml_set_character_data_handler() Function
Complete PHP XML Reference Manual
Definition and Usage
The xml_set_character_data_handler() function sets up a character data handler for an XML parser.
This function specifies the function to be called when the parser finds character data in an XML file.
On success, this function returns TRUE. On failure, it returns FALSE.
Syntax
xml_set_character_data_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 character data in string form from the XML file. |
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!
Complete PHP XML Reference Manual