PHP Tutorial - PHP xml_parser_set_option() Function

The xml_parser_set_option() function sets options in an XML parser.


PHP xml_parser_set_option() Function has the following syntax.



ParameterIs RequiredDescription
parserRequired.XML parser to use
optionRequired.option to set.
valueRequired.options new value

Possible values for option:

  • XML_OPTION_CASE_FOLDING - if case-folding is enabled. Enabled by default. Can be 1 (TRUE) or 0 (FALSE)
  • XML_OPTION_SKIP_TAGSTART - how many characters should be skipped in the beginning of a tag name
  • XML_OPTION_SKIP_WHITE - whether to skip values consisting of whitespace characters. Can be 1 (TRUE) or 0 (FALSE)
  • XML_OPTION_TARGET_ENCODING - which target encoding to use in this XML parser. By default, it is set to the same as the xml_parser_create() function. Supported target encodings are ISO-8859-1, US-ASCII and UTF-8.


This function returns TRUE on success, or FALSE on failure.


Set options in an XML parser

$xmlparser = xml_parser_create();

xml_parser_set_option($xmlparser, XML_OPTION_SKIP_WHITE, 1);