note 77263 added to ref.simplexml
| From: | (fireandknowledge.org) | Date: | Wed, 22 Aug 2007 02:40:01 +0000 |
| Subject: | note 77263 added to ref.simplexml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129687@lists.php.net to get a copy of this message | ||
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[] = '<![CDATA[';
$replace[] = '<![CDATA[';
$find[] = ']]>';
$replace[] = ']]>';
return $string = str_replace($find, $replace, $string);
}
$xml = fixCDATA( $xml->asXML() );
echo $xml;
?>
----
Server IP: 208.69.120.35
Probable Submitter: 24.118.30.112
----
Manual Page -- http://www.php.net/manual/en/ref.simplexml.php
Edit -- https://master.php.net/note/edit/77263
Del: integrated -- https://master.php.net/note/delete/77263/integrated
Del: useless -- https://master.php.net/note/delete/77263/useless
Del: bad code -- https://master.php.net/note/delete/77263/bad+code
Del: spam -- https://master.php.net/note/delete/77263/spam
Del: non-english -- https://master.php.net/note/delete/77263/non-english
Del: in docs -- https://master.php.net/note/delete/77263/in+docs
Del: other reasons-- https://master.php.net/note/delete/77263
Reject -- https://master.php.net/note/reject/77263
Search -- https://master.php.net/manage/user-notes.php