Answer the question
In order to leave comments, you need to log in
How to generate array from xml?
Hello!
There is XML
<category categories_id="62">
<categories_name>One</categories_name>
<categories_id>62</categories_id>
<parent_id>0</parent_id>
</category>
<category categories_id="652">
<categories_name>Two</categories_name>
<categories_id>652</categories_id>
<parent_id>62</parent_id>
</category>
<category categories_id="581">
<categories_name>Three</categories_name>
<categories_id>581</categories_id>
<parent_id>652</parent_id>
</category>
<category categories_id="581">
<categories_name>Three</categories_name>
<categories_id>581</categories_id>
<parent_id>652</parent_id>
</category><category categories_id="63">
<categories_name>One</categories_name>
<categories_id>63</categories_id>
<parent_id>0</parent_id>
</category>
<category categories_id="653">
<categories_name>Two</categories_name>
<categories_id>653</categories_id>
<parent_id>63</parent_id>
</category>
<category categories_id="583">
<categories_name>Three</categories_name>
<categories_id>583</categories_id>
<parent_id>653</parent_id>
</category>
Answer the question
In order to leave comments, you need to log in
$xml = simplexml_load_string($xml_string);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question