bug50576.phpt 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. --TEST--
  2. Bug #50576 (XML_OPTION_SKIP_TAGSTART option has no effect)
  3. --SKIPIF--
  4. <?php
  5. require_once("skipif.inc");
  6. ?>
  7. --FILE--
  8. <?php
  9. $XML = <<<XML
  10. <?xml version="1.0"?>
  11. <ns1:listOfAwards xmlns:ns1="http://www.fpdsng.com/FPDS">
  12. <ns1:count>
  13. <ns1:total>867</ns1:total>
  14. </ns1:count>
  15. </ns1:listOfAwards>
  16. XML;
  17. $xml_parser = xml_parser_create();
  18. xml_parser_set_option($xml_parser, XML_OPTION_SKIP_TAGSTART, 4);
  19. xml_parse_into_struct($xml_parser, $XML, $vals, $index);
  20. echo 'Index array' . PHP_EOL;
  21. print_r($index);
  22. echo 'Vals array' . PHP_EOL;
  23. print_r($vals);
  24. xml_parser_free($xml_parser);
  25. function startElement($parser, $name, $attribs) { echo $name . PHP_EOL; }
  26. function endElement($parser, $name) { echo $name . PHP_EOL; }
  27. $xml_parser = xml_parser_create();
  28. xml_set_element_handler($xml_parser, 'startElement', 'endElement');
  29. xml_parser_set_option($xml_parser, XML_OPTION_SKIP_TAGSTART, 4);
  30. xml_parse($xml_parser, $XML);
  31. xml_parser_free($xml_parser);
  32. ?>
  33. --EXPECTF--
  34. Index array
  35. Array
  36. (
  37. [LISTOFAWARDS] => Array
  38. (
  39. [0] => 0
  40. [1] => 5
  41. [2] => 6
  42. )
  43. [COUNT] => Array
  44. (
  45. [0] => 1
  46. [1] => 3
  47. [2] => 4
  48. )
  49. [TOTAL] => Array
  50. (
  51. [0] => 2
  52. )
  53. )
  54. Vals array
  55. Array
  56. (
  57. [0] => Array
  58. (
  59. [tag] => LISTOFAWARDS
  60. [type] => open
  61. [level] => 1
  62. [attributes] => Array
  63. (
  64. [XMLNS:NS1] => http://www.fpdsng.com/FPDS
  65. )
  66. [value] =>
  67. )
  68. [1] => Array
  69. (
  70. [tag] => COUNT
  71. [type] => open
  72. [level] => 2
  73. [value] =>
  74. )
  75. [2] => Array
  76. (
  77. [tag] => TOTAL
  78. [type] => complete
  79. [level] => 3
  80. [value] => 867
  81. )
  82. [3] => Array
  83. (
  84. [tag] => COUNT
  85. [value] =>
  86. [type] => cdata
  87. [level] => 2
  88. )
  89. [4] => Array
  90. (
  91. [tag] => COUNT
  92. [type] => close
  93. [level] => 2
  94. )
  95. [5] => Array
  96. (
  97. [tag] => LISTOFAWARDS
  98. [value] =>
  99. [type] => cdata
  100. [level] => 1
  101. )
  102. [6] => Array
  103. (
  104. [tag] => LISTOFAWARDS
  105. [type] => close
  106. [level] => 1
  107. )
  108. )
  109. LISTOFAWARDS
  110. COUNT
  111. TOTAL
  112. TOTAL
  113. COUNT
  114. LISTOFAWARDS