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