xref: /PHP-5.3/ext/xml/tests/xml004.phpt (revision d0c535d0)
1--TEST--
2XML parser case folding test
3--SKIPIF--
4<?php include("skipif.inc"); ?>
5--INI--
6magic_quotes_runtime=0
7--FILE--
8<?php
9chdir(dirname(__FILE__));
10
11$xp = xml_parser_create();
12xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false);
13xml_set_element_handler($xp, "start_element", "end_element");
14$fp = fopen("xmltest.xml", "r");
15while ($data = fread($fp, 4096)) {
16	xml_parse($xp, $data, feof($fp));
17}
18xml_parser_free($xp);
19$xp = xml_parser_create();
20xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, true);
21xml_set_element_handler($xp, "start_element", "end_element");
22$fp = fopen("xmltest.xml", "r");
23while ($data = fread($fp, 4096)) {
24	xml_parse($xp, $data, feof($fp));
25}
26xml_parser_free($xp);
27
28function start_element($xp, $elem, $attribs)
29{
30	print "<$elem";
31	if (sizeof($attribs)) {
32		while (list($k, $v) = each($attribs)) {
33			print " $k=\"$v\"";
34		}
35	}
36	print ">\n";
37}
38
39function end_element($xp, $elem)
40{
41	print "</$elem>\n";
42}
43?>
44--EXPECT--
45<root id="elem1">
46<elem1>
47<elem2>
48<elem3>
49<elem4>
50</elem4>
51</elem3>
52</elem2>
53</elem1>
54</root>
55<ROOT ID="elem1">
56<ELEM1>
57<ELEM2>
58<ELEM3>
59<ELEM4>
60</ELEM4>
61</ELEM3>
62</ELEM2>
63</ELEM1>
64</ROOT>
65