|
|
| |
1. XML to array in one simple call |
|
Reply |
|
|
 bastien koert | 2012-09-13 15:05:05 |
I found this when I needed to turn some XML into an array for processing
json_decode(json_encode((array) simplexml_load_string($xml)),1);
works great! |
| |
2. Re: XML to array in one simple call |
|
Reply |
|
|
 Manuel Lemos | 2012-09-13 15:29:21 - In reply to message 1 from bastien koert |
I wonder if it really needed to encode and decode it as JSON.
Anyway, extracting is just one part of the job that is usually necessary. Validating is often necessary to write robust software by assuring you are not processing unexpected data. |
| |
3. Re: XML to array in one simple call |
|
Reply |
|
|
 Sean Benoit | 2012-12-05 13:29:14 - In reply to message 1 from bastien koert |
| Love this suggestion, just used it on a project I'm working on. |
| |
4. Re: XML to array in one simple call |
|
Reply |
|
|
 Manuel Lemos | 2012-12-05 19:18:45 - In reply to message 3 from Sean Benoit |
| I am glad you like it. It is so much simpler than having to write loads of code. |
|