Answer the question
In order to leave comments, you need to log in
How to parse xml in php keeping the order of child elements without concatenating into an array?
I broke my head, I need smart thoughts!
When parsing xml into an array in php, I use the xml->dom->json->array chain. In this case, if the child elements are the same, then they are collected in an array, and if they are different, then in several arrays. The problem is that I need to know exactly the order of the elements in the xml. or save it.
Xml has the following structure:
<m>
<a>
<p/>
<r>7</r>
<a>
<d/>
<r>2</r>
<r>5</r>
</a>
</a>
<i>p</i>
<i>p</i>
<r>3</r>
<r>3</r>
<i>p</i>
</m>
[0] => <a>(*?)</a>,
[1] => <i>p<i>,
и т.д.
<m>
<a n="0">(*?)</a>
<i n="1">p</i>
и т.д.
</m>
Answer the question
In order to leave comments, you need to log in
and than simpleXml did not suit? the order does not change, the output is an object that inherits ArrayAccess
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question