Add basic xmlwriter_write_cdata() example

This integrates user note 85621.

To render the example output as desired, we have to hack by inserting
a zero-width space character between the two brakets of the cdata end
marker.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@350606 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Christoph Michael Becker 2020-09-20 17:38:05 +00:00
parent 2716a63905
commit 7c015620f9

View file

@ -48,6 +48,46 @@
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example xml:id="xmlwriter-write-cdata.example.basic">
<title>Basic <function>xmlwriter_write_cdata</function> Usage</title>
<programlisting role="php">
<![CDATA[
<?php
// set up the document
$xml = new XmlWriter();
$xml->openMemory();
$xml->setIndent(true);
$xml->startDocument('1.0', 'UTF-8');
$xml->startElement('mydoc');
$xml->startElement('myele');
// CData output
$xml->startElement('mycdataelement');
$xml->writeCData("text for inclusion as CData");
$xml->endElement();
// end the document and output
$xml->endElement();
$xml->endElement();
echo $xml->outputMemory(true);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
<mydoc>
<myele>
<mycdataelement><![CDATA[text for inclusion as CData]]></mycdataelement>
</myele>
</mydoc>
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>