xref: /PHP-5.4/ext/xmlwriter/tests/OO_009.phpt (revision 92b6f242)
1--TEST--
2XMLWriter: PI, Comment, CDATA
3--SKIPIF--
4<?php
5if (!extension_loaded("xmlwriter")) die("skip");
6?>
7--FILE--
8<?php
9/* $Id$ */
10/*
11Libxml 2.6.24 and up adds a new line after a processing instruction (PI)
12*/
13$xw = new XMLWriter();
14$xw->openMemory();
15$xw->setIndent(TRUE);
16$xw->startDocument("1.0", "UTF-8");
17$xw->startElement('root');
18$xw->writeAttribute('id', 'elem1');
19$xw->startElement('elem1');
20$xw->writeAttribute('attr1', 'first');
21$xw->writeComment('start PI');
22$xw->startElement('pi');
23$xw->writePi('php', 'echo "hello world"; ');
24$xw->endElement();
25$xw->startElement('cdata');
26$xw->startCdata();
27$xw->text('<>&"');
28$xw->endCdata();
29$xw->endElement();
30$xw->endElement();
31$xw->endElement();
32$xw->endDocument();
33// Force to write and empty the buffer
34$output = $xw->flush(true);
35print $output;
36?>
37--EXPECTF--
38<?xml version="1.0" encoding="UTF-8"?>
39<root id="elem1">
40 <elem1 attr1="first">
41  <!--start PI-->
42  <pi><?php echo "hello world"; ?>%w</pi>
43  <cdata><![CDATA[<>&"]]></cdata>
44 </elem1>
45</root>
46