note 77263 deleted from ref.simplexml by danbrown

From: Date: Mon, 18 May 2009 01:19:05 +0000
Subject: note 77263 deleted from ref.simplexml by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155514@lists.php.net to get a copy of this message
Note Submitter: Josh Sowin (fireandknowledge.org) ---- You can't use CDATA with SimpleXML, but there is a way around it. Wrap your child in CDATA like this: <? $listing->addChild( 'description', '<![CDATA[' . $row['description'] . ']]>' ); ?> And then when you display the XML, run it through this function: <? function fixCDATA($string) { $find[] = '&lt;![CDATA['; $replace[] = '<![CDATA['; $find[] = ']]&gt;'; $replace[] = ']]>'; return $string = str_replace($find, $replace, $string); } $xml = fixCDATA( $xml->asXML() ); echo $xml; ?>

« previous php.notes (#155514) next »