xref: /php-src/ext/xml/tests/bug70962.phpt (revision cc5ec597)
1--TEST--
2Bug #70962 (XML_OPTION_SKIP_WHITE strips embedded whitespace)
3--EXTENSIONS--
4xml
5--FILE--
6<?php
7function parseAndOutput($xml)
8{
9    $parser = xml_parser_create();
10    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
11
12    xml_parse_into_struct($parser, $xml, $values);
13
14    return $values;
15}
16
17$xml = "<a><b>&lt;d&gt;\n &lt;e&gt;</b><![CDATA[  ]]><c>\n \t</c></a>";
18
19$parsed = parseAndOutput($xml);
20
21// Check embedded whitespace is not getting skipped.
22echo $parsed[1]['value'] . "\n";
23
24// Check XML_OPTION_SKIP_WHITE ignores values of tags containing whitespace characters only.
25var_dump(isset($parsed[2]['value']));
26
27// Check XML_OPTION_SKIP_WHITE ignores empty <![CDATA[  ]]> values.
28var_dump(count($parsed));
29
30?>
31--EXPECT--
32<d>
33 <e>
34bool(false)
35int(4)
36