PageRenderTime 53ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/facebook/hiphop-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
  1. <?hh
  2. function read_xml($skip_white) {
  3. $xml=file_get_contents(__DIR__."/skipwhite.xml");
  4. $parser=xml_parser_create();
  5. xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
  6. xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,$skip_white);
  7. xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,"UTF-8");
  8. $array=varray[];
  9. $index=varray[];
  10. xml_parse_into_struct($parser,$xml,inout $array, inout $index);
  11. return $array;
  12. }
  13. function find_node($array,$node) {
  14. foreach($array as $key=>$val) {
  15. if($val["tag"]==$node) return $val;
  16. }
  17. return varray[];
  18. }
  19. // WITH XML_OPTION_SKIP_WHITE=0 WORKS FINE
  20. <<__EntryPoint>>
  21. function main_xml_option_skip_white() {
  22. $array=read_xml(0);
  23. $node=find_node($array,"query");
  24. print_r($node);
  25. // WITH XML_OPTION_SKIP_WHITE=1 FAILS
  26. $array=read_xml(1);
  27. $node=find_node($array,"query");
  28. print_r($node);
  29. }