20.8 Setting and Getting Options


You want to control or view certain aspects of the way PHP handles XML processing.

Technique

Use the xml_parser_set_option() and the xml_parser_get_option() functions:

 <?php $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); // defaults to 1 xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); // defaults to ISO-8859-1 $skip_white = xml_parser_get_option($parser, XML_OPTION_SKIP_WHITE); ?> 

Comments

You can get and set four options by using the xml_parser_get_option() and xml_parser_set_option() functions. Here is a list of the constants and their values:

XML_OPTION_CASE_FOLDING ” Whether to change all the elements' cases to uppercase while parsing. For example, <title></title> would become <TITLE></TITLE> .

XML_OPTION_TARGET_ENCODING ” The type of target encoding. It defaults to ISO-8859-1, but you can set it to either UTF-8 or US-ASCII.

XML_OPTION_SKIP_WHITE ” None yet

XML_OPTION_SKIP_TAGSTART ” None yet

These four constants are the only things that you can set, but the rest of the XML API is pretty flexible, so you shouldn't have to worry about not having enough flexibility or power.



PHP Developer's Cookbook
PHP Developers Cookbook (2nd Edition)
ISBN: 0672323257
EAN: 2147483647
Year: 2000
Pages: 351

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net