xref: /PHP-8.3/ext/xml/tests/xml011.phpt (revision 8567bc10)
1--TEST--
2XML Parser test: concat character data and set empty handlers
3--EXTENSIONS--
4xml
5--FILE--
6<?php
7function start_elem($parser,$name,$attribs) {
8   echo "<$name>";
9}
10function end_elem()
11{
12   echo "</$name>";
13}
14
15$xml = '<text>start<b /> This &amp; that</text>';
16
17$parser = xml_parser_create();
18xml_parse_into_struct($parser, $xml, $vals, $index);
19print_r($vals);
20xml_parser_free($parser);
21
22echo "\nChange to empty end handler\n";
23$parser = xml_parser_create();
24xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
25xml_set_element_handler($parser,'start_elem','end_elem');
26xml_set_element_handler($parser,'start_elem',NULL);
27xml_parse($parser, $xml, TRUE);
28
29xml_parser_free($parser);
30echo "\nDone\n";
31?>
32--EXPECT--
33Array
34(
35    [0] => Array
36        (
37            [tag] => TEXT
38            [type] => open
39            [level] => 1
40            [value] => start
41        )
42
43    [1] => Array
44        (
45            [tag] => B
46            [type] => complete
47            [level] => 2
48        )
49
50    [2] => Array
51        (
52            [tag] => TEXT
53            [value] =>  This & that
54            [type] => cdata
55            [level] => 1
56        )
57
58    [3] => Array
59        (
60            [tag] => TEXT
61            [type] => close
62            [level] => 1
63        )
64
65)
66
67Change to empty end handler
68<text><b>
69Done
70