note 54676 deleted from function.simplexml-load-file by danbrown
| From: | danbrown@php.net | Date: | Thu, 24 Jul 2008 13:32:46 +0000 |
| Subject: | note 54676 deleted from function.simplexml-load-file by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142658@lists.php.net to get a copy of this message | ||
Note Submitter: pa ul at sant a soft dot co m
----
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.