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