Re: Issues with simplexml_load_string()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 6, 2011 at 9:50 PM, Christoph Boget <jcboget@xxxxxxxxxxx> 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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux