PHP Function Reference

PHP xml_parser_get_option() Function



The PHP xml_parser_get_option() function gets an option value from an XML parser.

Syntax

xml_parser_get_option(parser, option)

Parameters

parser Required. Specify a reference to the XML parser to get an option from.
option Required. Specify the option to get. Possible values are:
  • XML_OPTION_CASE_FOLDING: Specifies if case-folding is enabled. Default is enabled.
  • XML_OPTION_SKIP_TAGSTART: Specifies how many characters that is skipped in the beginning of a tag name.
  • XML_OPTION_SKIP_WHITE: Specifies whether to skip values consisting of whitespace characters.
  • XML_OPTION_TARGET_ENCODING: Specifies the target encoding in this XML parser. Set to the same as the xml_parser_create() function. Supported target encodings are ISO-8859-1, US-ASCII and UTF-8.

Return Value

Returns false if parser does not refer to a valid parser or if option is not valid (generates also a E_WARNING). Otherwise the option's value is returned.

Example:

In the example below, an XML parser is created using xml_parser_create() function. Then, the xml_parser_get_option() function is used to get the option value of this XML parser.

<?php
//create an XML parser
$parser=xml_parser_create();

//getting option value of the XML parser
echo "XML_OPTION_CASE_FOLDING: ". 
    xml_parser_get_option($parser, XML_OPTION_CASE_FOLDING) ."<br>";
echo "XML_OPTION_SKIP_TAGSTART: ". 
    xml_parser_get_option($parser, XML_OPTION_SKIP_TAGSTART) ."<br>";
echo "XML_OPTION_SKIP_WHITE: ". 
    xml_parser_get_option($parser, XML_OPTION_SKIP_WHITE) ."<br>";
echo "XML_OPTION_TARGET_ENCODING: ". 
    xml_parser_get_option($parser, XML_OPTION_TARGET_ENCODING) ."<br>";

//free XML parser
xml_parser_free($parser);
?>

The output of the above code will be:

XML_OPTION_CASE_FOLDING: 1
XML_OPTION_SKIP_TAGSTART: 0
XML_OPTION_SKIP_WHITE: 0
XML_OPTION_TARGET_ENCODING: UTF-8

❮ PHP XML Parser Reference