PHP xml_parser_set_option() Function

In this chapter you will learn:

  1. Description for PHP xml_parser_set_option() Function
  2. Syntax for PHP xml_parser_set_option() Function
  3. Parameter for PHP xml_parser_set_option() Function
  4. Return for PHP xml_parser_set_option() Function
  5. Example - sets options in an XML parser

Description

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

Syntax

PHP xml_parser_set_option() Function has the following syntax.

xml_parser_set_option(parser,option,value)

Parameter

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.

Return

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

Example

Set options in an XML parser


<?php/*from j  a  v  a  2  s .  co m*/
$xmlparser = xml_parser_create();

xml_parser_set_option($xmlparser, XML_OPTION_SKIP_WHITE, 1);

xml_parser_free($xmlparser);
?>

Next chapter...

What you will learn in the next chapter:

  1. Description for PHP xml_set_character_data_handler() Function
  2. Syntax for PHP xml_set_character_data_handler() Function
  3. Parameter for PHP xml_set_character_data_handler() Function
  4. Notes for PHP xml_set_character_data_handler() Function
  5. Return for PHP xml_set_character_data_handler() Function
  6. Example - Set the character data handler for the XML parser