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