mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
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:
parent
2716a63905
commit
7c015620f9
1 changed files with 40 additions and 0 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue