parse complex xml with php in MD array -


i've been looking around this, can't quite seem find answer. have complex xml document need parse php. structure of xml looks this:

<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> 

it important parse document multidimensional array same structure.

there 1 problem, however. there no way of knowing how many sub-levels there inside of first tag, if @ all. document dynamically created system, , sub-structure of each main tag different.
tried using simplexmlelement, parsed first level, i.e. data between main tag , first sub tag.

try simplexml_load_string():

<?php $string = <<<xml <?xml version='1.0'?>  <document>  <title>forty what?</title>  <from>joe</from>  <to>jane</to>  <body>   know that's answer -- what's question?  </body> </document> xml;  $xml = simplexml_load_string($string);  print_r($xml); 

doesn't matter how many levels have or structure is.. long it's valid you'll object can work with.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -