PHP Function XML_Set_Character_Data_Handler()
The php function xml_set_character_data_handler() sets a user defined function as the handler for character data when parsing XML. This is a useful function to use when you want to manipulate the character data such as trimming out whitespace or performing other transformations on it. The xml_set_character_data_handler() function takes two arguments, $parser and the name of the user defined function that you want to set as the handler. The xml_set_character_data_handler() functions also accepts two optional arguments, XML_OPTION_CASE_FOLDING which allows you to control whether or not the character data is case folded and XML_OPTION_SKIP_TAGSTART which sets how many characters at the start of the tag name will be skipped.
This is just one of a suite of php functions that you can use to assemble a highly customized XML parser step by step. The other php functions are xml_set_external_entity_ref_handler() for setting up the external entity reference handler, xml_set_processing_instruction_handler() for setting up the processing instruction handler, xml_set_notation_decl_handler() for setting up the notation declaration handler and xml_set_element_handler() for setting up the element handler.
This function is called when the xml_parser object you created in the xml_parser_create() call encounters character data that it needs to handle. This is a good time to do any cleanup or work on the data that you are parsing. Just remember that if you used the cdata tag then the parser will return the data within those tags so you don't have to worry about cutting out all the whitespace.