Re: Issues with simplexml_load_string()
| From: | Benjamin Hawkes-Lewis | Date: | Fri, 07 Oct 2011 06:53:44 +0000 |
| Subject: | Re: Issues with simplexml_load_string() | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-315164@lists.php.net to get a copy of this message | ||
On Thu, Oct 6, 2011 at 9:50 PM, Christoph Boget <jcboget@hotmail.com> wrote:
> It seems like when dealing with nodes which have CDATA, I cannot get
> access to both the attributes of that node and the CDATA of that node
> with the same simplexml_load_string() call. Consider the following:
>
> $previewString =
>
> '<root><message><![CDATA[lkjlkjklj]]></message><buttons><button
> name="Add Me"><![CDATA[This is my free form
> text]]></button></buttons></root>';
>
> When passing LIBXML_NOCDATA:
>
> echo '<pre>' . print_r( json_decode( json_encode(
> (array)simplexml_load_string( $previewString, 'SimpleXMLElement',
> LIBXML_NOCDATA | LIBXML_NOBLANKS )), 1 ), TRUE ) . '</pre>';
>
> yields the following output :
>
> Array
> (
> [message] => lkjlkjklj
> [buttons] => Array
> (
> [button] => This is my free form text
> )
> )
>
> So I get the CDATA but I don't get the "name" attribute for the button.
http://us.php.net/manual/en/function.simplexml-load-string.php#80855
maybe?
--
Benjamin Hawkes-Lewis