bug50576.phpt 2.4 KB

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