hiphop-php /hphp/test/slow/ext_xml/xml_Option_Skip_White.php

Language PHP Lines 30
MD5 Hash ea3ac97f3f94e78066a7464e118ecdfc Estimated Cost $515 (why?)
Repository git://github.com/facebook/hiphop-php.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
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=array();
  $index=array();
  xml_parse_into_struct($parser,$xml,$array,$index);
  return $array;
}

function find_node($array,$node) {
  foreach($array as $key=>$val) {
    if($val["tag"]==$node) return $val;
  }
  return array();
}

// WITH XML_OPTION_SKIP_WHITE=0 WORKS FINE
$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);
Back to Top