]> granicus.if.org Git - php/blob
c04ffe3167
[php] /
1 --TEST--
2 Bug #41287 (Writing empty tags with Xmlwriter::WriteElement[ns])
3 --SKIPIF--
4 <?php
5 if (!extension_loaded("xmlwriter")) die("skip");
6 ?>
7 --FILE--
8 <?php
9 $xml = new XmlWriter();
10 $xml->openMemory();
11 $xml->setIndent(true);
12 $xml->startDocument();
13 $xml->startElement('test');
14 $xml->writeElement('foo', null);
15 $xml->writeElement('foo2', "");
16 $xml->writeElement('foo3');
17 $xml->startElement('bar');
18 $xml->endElement();
19 $xml->endElement();
20 print $xml->flush(true);
21
22 print "\n";
23
24 $xw = new XMLWriter();
25 $xw->openMemory();
26 $xw->setIndent(true);
27 $xw->startDocument();
28 $xw->startElementNS('test', 'test', 'urn:x-test:');
29 $xw->writeElementNS('test', 'foo', null, '');
30 $xw->writeElementNS(null, 'bar', 'urn:x-test:', '');
31 $xw->writeElementNS(null, 'bar', 'urn:x-test:', NULL);
32 $xw->writeElementNS(null, 'bar', 'urn:x-test:');
33 $xw->writeElementNS(null, 'bar', '', '');
34 $xw->endElement();
35 $xw->endDocument();
36 print $xw->flush(true);
37 ?>
38 --EXPECT--
39 <?xml version="1.0"?>
40 <test>
41  <foo/>
42  <foo2></foo2>
43  <foo3/>
44  <bar/>
45 </test>
46
47 <?xml version="1.0"?>
48 <test:test xmlns:test="urn:x-test:">
49  <test:foo></test:foo>
50  <bar xmlns="urn:x-test:"></bar>
51  <bar xmlns="urn:x-test:"/>
52  <bar xmlns="urn:x-test:"/>
53  <bar xmlns=""></bar>
54 </test:test>