parse complex xml with php in MD array

divinifer

New Member
I've been looking around for this, but can't quite seem to find the answer.I have a fairly complex XML document that I need to parse with PHP. The structure of XML looks like this:\[code\]<root><main id="1"> *some data*<sub id="1"> *some data* <sub id="2"> *some data* <sub id="3"> *some data* <sub id="4"> *some data* </sub> <sub id="5"> *some data* </sub> </sub> </sub></sub></main></root>\[/code\]It is very important to parse this document into a multidimensional array with same structure. There is one problem, however. There is no way of knowing how many sub-levels there are inside of a first tag, if any at all. This document is dynamically created by another system, and the sub-structure of each main tag is different.
I tried using SimpleXMLElement, but it only parsed the first level, i.e. the data between the main tag and the first sub tag.Thank you!
 
Back
Top