Re: [PHP] Issues with simplexml_load_string()
> http://us.php.net/manual/en/function.simplexml-load-string.php#80855 maybe? Thanks for that. I guess I should have scrolled a little further down. It's so crazy that it works that way. Unless you export the actual element (and not it's ancestors), you don't see the data at all. thnx, Christoph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Issues with simplexml_load_string()
On Thu, Oct 6, 2011 at 9:50 PM, Christoph Boget 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 = > ' name="Add Me">'; > > When passing LIBXML_NOCDATA: > > echo '' . print_r( json_decode( json_encode( > (array)simplexml_load_string( $previewString, 'SimpleXMLElement', > LIBXML_NOCDATA | LIBXML_NOBLANKS )), 1 ), TRUE ) . ''; > > 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
[PHP] Issues with simplexml_load_string()
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 = ''; When passing LIBXML_NOCDATA: echo '' . print_r( json_decode( json_encode( (array)simplexml_load_string( $previewString, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NOBLANKS )), 1 ), TRUE ) . ''; 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. When not using LIBXML_NOCDATA: echo '' . print_r( json_decode( json_encode((array)simplexml_load_string( $previewString, 'SimpleXMLElement', LIBXML_NOBLANKS )), 1 ), TRUE ) . ''; yields the following output : Array ( [message] => Array ( ) [buttons] => Array ( [button] => Array ( [@attributes] => Array ( [name] => Add Me ) ) ) ) I get the attributes but not the CDATA. Looking at the doc page for simplexml_load_string() (http://us.php.net/manual/en/function.simplexml-load-string.php and http://us.php.net/manual/en/libxml.constants.php), I don't see a way to get access to both. Am I missing something? Or is this really not possible? thnx, Christoph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Issues with simplexml_load_string()
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 = ''; When passing LIBXML_NOCDATA: echo '' . print_r( json_decode( json_encode( (array)simplexml_load_string( $previewString, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NOBLANKS )), 1 ), TRUE ) . ''; 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. When not using LIBXML_NOCDATA: echo '' . print_r( json_decode( json_encode( (array)simplexml_load_string( $previewString, 'SimpleXMLElement', LIBXML_NOBLANKS )), 1 ), TRUE ) . ''; yields the following output : Array ( [message] => Array ( ) [buttons] => Array ( [button] => Array ( [@attributes] => Array ( [name] => Add Me ) ) ) ) I get the attributes but not the CDATA. Looking at the doc page for simplexml_load_string() (http://us.php.net/manual/en/function.simplexml-load-string.php and http://us.php.net/manual/en/libxml.constants.php), I don't see a way to get access to both. Am I missing something? Or is this really not possible? thnx, Christoph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php