PHP Function XML_Parser_Set_Option
The php function xml_parser_set_option is an inbuilt function that allows you to set options in an XML parser. The function has the following syntax:
xml_parser_set_option() sets a number of options in an XML parser object. The options are:
start element handler – This is a callback reference to a function that will be called when a start element is found as the parser runs. Similarly, end element handler – This is a function that will be called when an end element is found as the parser runs.
character data handler – This is a callback that will be called when the parser encounters character data such as in CDATA tags.
encodings
As the name suggests, this option specifies which encodings are used for both source input to the parser and data output from it. Currently supported encodings are ISO-8859-1, US-ASCII and UTF-8.
XML_OPTION_CASE_FOLDING – This is the default value and enables case-folding, which reduces the amount of memory required to store XML documents.
XML_OPTION_SKIP_TAGSTART – This specifies the number of characters to skip at the beginning of a tag name.
Note that the function declaration MUST be before the call to xml_parser_set_element_handler(), and also the call to xml_parser_set_character_data_handler(). This is to ensure that the xml_parser object knows about these functions so it can point them towards the right handlers. If the xml_parser is not configured with these function declarations then it will ignore them and will pass the input data directly to the output.