/hphp/test/slow/ext_xml/xml_Option_Skip_White.php
PHP | 33 lines | 27 code | 4 blank | 2 comment | 1 complexity | c14a77d2dd26a86712c71618afd65995 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
- <?hh
- function read_xml($skip_white) {
- $xml=file_get_contents(__DIR__."/skipwhite.xml");
- $parser=xml_parser_create();
- xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
- xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,$skip_white);
- xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,"UTF-8");
- $array=varray[];
- $index=varray[];
- xml_parse_into_struct($parser,$xml,inout $array, inout $index);
- return $array;
- }
- function find_node($array,$node) {
- foreach($array as $key=>$val) {
- if($val["tag"]==$node) return $val;
- }
- return varray[];
- }
- // WITH XML_OPTION_SKIP_WHITE=0 WORKS FINE
- <<__EntryPoint>>
- function main_xml_option_skip_white() {
- $array=read_xml(0);
- $node=find_node($array,"query");
- print_r($node);
- // WITH XML_OPTION_SKIP_WHITE=1 FAILS
- $array=read_xml(1);
- $node=find_node($array,"query");
- print_r($node);
- }