xref: /PHP-8.2/ext/xmlwriter/tests/OO_013.phpt (revision 74859783)
1--TEST--
2XMLWriter: libxml2 XML Writer, Write Raw
3--CREDITS--
4Mark Baker mark@lange.demon.co.uk at the PHPNW2017 Conference for PHP Testfest 2017
5--EXTENSIONS--
6xmlwriter
7--FILE--
8<?php
9
10$cDataString = "<cdataElement><![CDATA[Text for inclusion within CData tags can include characters like <, >, &, and quotes like ' and \"]]></cdataElement>";
11$xmlWriter = new XmlWriter();
12$xmlWriter->openMemory();
13
14$xmlWriter->startDocument('1.0', 'UTF-8');
15$xmlWriter->startElement('myDocumentRoot');
16$xmlWriter->startElement('myElement');
17// CData output
18$xmlWriter->writeRaw($cDataString);
19// end the document and output
20$xmlWriter->endElement();
21$xmlWriter->endElement();
22
23echo $xmlWriter->outputMemory(true);
24
25?>
26--EXPECT--
27<?xml version="1.0" encoding="UTF-8"?>
28<myDocumentRoot><myElement><cdataElement><![CDATA[Text for inclusion within CData tags can include characters like <, >, &, and quotes like ' and "]]></cdataElement></myElement></myDocumentRoot>
29