Annotation of embedaddon/php/ext/xml/tests/xml_closures_001.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: XML parser test using closures as callbacks
3: --SKIPIF--
4: <?php include("skipif.inc"); ?>
5: --INI--
6: magic_quotes_runtime=0
7: --FILE--
8: <?php
9: chdir(dirname(__FILE__));
10:
11: $start_element = function ($xp, $elem, $attribs)
12: {
13: print "<$elem";
14: if (sizeof($attribs)) {
15: while (list($k, $v) = each($attribs)) {
16: print " $k=\"$v\"";
17: }
18: }
19: print ">\n";
20: };
21:
22: $end_element = function ($xp, $elem)
23: {
24: print "</$elem>\n";
25: };
26:
27: $xp = xml_parser_create();
28: xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false);
29: xml_set_element_handler($xp, $start_element, $end_element);
30: $fp = fopen("xmltest.xml", "r");
31: while ($data = fread($fp, 4096)) {
32: xml_parse($xp, $data, feof($fp));
33: }
34: xml_parser_free($xp);
35:
36: ?>
37: --EXPECT--
38: <root id="elem1">
39: <elem1>
40: <elem2>
41: <elem3>
42: <elem4>
43: </elem4>
44: </elem3>
45: </elem2>
46: </elem1>
47: </root>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>