summaryrefslogtreecommitdiff
path: root/ext/xml/tests/xml011.phpt
blob: 9c4cfca8f14ac65cf036e24e6879733737f2bc2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
--TEST--
XML Parser test: concat character data and set empty handlers
--SKIPIF--
<?php
require_once("skipif.inc");
?>
--FILE--
<?php
function start_elem($parser,$name,$attribs) {
   echo "<$name>";
}
function end_elem()
{
   echo "</$name>";
}

$xml = '<text>start<b /> This &amp; that</text>';

$parser = xml_parser_create();
xml_parse_into_struct($parser, $xml, $vals, $index);
print_r($vals);
xml_parser_free($parser);

echo "\nChange to empty end handler\n";
$parser = xml_parser_create();
xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
xml_set_element_handler($parser,'start_elem','end_elem');
xml_set_element_handler($parser,'start_elem',NULL);
xml_parse($parser, $xml, TRUE);

xml_parser_free($parser);
echo "\nDone\n";
?>
--EXPECT--
Array
(
    [0] => Array
        (
            [tag] => TEXT
            [type] => open
            [level] => 1
            [value] => start
        )

    [1] => Array
        (
            [tag] => B
            [type] => complete
            [level] => 2
        )

    [2] => Array
        (
            [tag] => TEXT
            [value] =>  This & that
            [type] => cdata
            [level] => 1
        )

    [3] => Array
        (
            [tag] => TEXT
            [type] => close
            [level] => 1
        )

)

Change to empty end handler
<text><b>
Done