note 54676 added to function.simplexml-load-file

From: Date: Tue, 12 Jul 2005 14:34:39 +0000
Subject: note 54676 added to function.simplexml-load-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-91812@lists.php.net to get a copy of this message
One thing to note about the object2array function from aleshru below... this function doesn't handle CDATA fields (e.g. a poorly formed HTML formatted message.) It just returns an empty array. example XML: --------------8<--------------- <note> <subject>HTML Message Dude!</subject> <content><![CDATA[ <B> this is some </b> CDATA data that is useful to handle or at least see. <div> it doesn't matter that the HTML isn't properly </di>v opened or closed. <br> the html content is still continuing!!]]></content> </note> --------------8<--------------- the simpleXML built in functionality seems to handle this just dandily however. <?php $object = simplexml_load_string($that_string_of_xml_above); echo ((string) $object->content); /* OUTPUT: <B> this is some </b> CDATA data that is useful to handle or at least see. <div> it doesn't matter that the HTML isn't properly </di>v opened or closed. <br> the html content is still continuing!! */ ?> This object2array function does work well for the other types of xml content however. ---- Manual Page -- http://www.php.net/manual/en/function.simplexml-load-file.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54676 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54676&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54676&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54676&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54676&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54676&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54676&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54676&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#91812) next »