suche nach in der

XMLWriter->writeComment> <XMLWriter->writeAttribute
Last updated: Fri, 25 May 2012

view this page in

XMLWriter->writeCData

xmlwriter_write_cdata

(PHP 5 >= 5.1.2, PECL xmlwriter >= 0.1.0)

XMLWriter->writeCData -- xmlwriter_write_cdataKompletten CDATA-Block schreiben

Beschreibung

Objektorientierter Stil

bool XMLWriter::writeCData ( string $content )

Prozeduraler Stil

bool xmlwriter_write_cdata ( resource $xmlwriter , string $content )

Schreibt einen vollständigen CDATA-Block.

Parameter-Liste

xmlwriter

Nur für prozedurale Aufrufe. Die XMLWriter-resource, die bearbeitet werden soll. Diese Ressource wird von Aufrufen von xmlwriter_open_uri() oder xmlwriter_open_memory() geliefert.

content

Inhalt des CDATA-Blocks.

Rückgabewerte

Gibt bei Erfolg TRUE zurück. Im Fehlerfall wird FALSE zurückgegeben.

Siehe auch



add a note add a note User Contributed Notes
XMLWriter->writeCData
thesoupdragon at hotmail dot com
21-Jun-2007 11:14
A rather strange effect with this.

UTF8 Mysql database

                            $xml->startElement('tablecolor2');
    $xml->writeCData( $tablecolor2 );
    $xml->endElement();

does not work !

but
                            $xml->startElement('tablecolor2');
    $tablecolor2 = utf8_decode ( $val['pcolor2']);
    $xml->writeCData( utf8_encode ($tablecolor2) );
    $xml->endElement();

cannot explain this - but it may help someone
dave at dtracorp dot com
06-Mar-2007 10:30
i don't know if this is a bug with the underlying c code or not, or this is by design (i'm not a big xml guy), but for me, running on fedora core 5, php 5.2.1
to get this to work, the cdata functions need to wrap the description (or whatever element the cdata should appear in)
for example.
// initiate xmlwriter object as $xw
// add header, titles, etc.

// start cdata
$xw->startCData();
// start description
$xw->startElement('description');
// write cdata
$xw->writeCData('<img src="http://php.net/images/php.gif" />');
// write the description contents
$xw->text('php logo');
// end the description element
$xw->endElement();
// end the cdata
$xw->endCData();

// end xml, and output

otherwise, i just got warnings about writing cdata in the wrong context, and no cdata would be written

XMLWriter->writeComment> <XMLWriter->writeAttribute
Last updated: Fri, 25 May 2012