There are noumerous questions on converting XML to array, and simpliest method is as follows:
$data = unserialize(serialize(json_decode(json_encode((array)simplexml_load_string($dataXml)), 1)));
However, I cant get attributes names using this approach, and could not find any questions on SO, explaining how to do it.
Here is part of XML that I have:
<Object>
<attribute name="Surname">Ярош</attribute>
<attribute name="Name">Анна</attribute>
<attribute name="Middle name">Григорьевна</attribute>
<attribute name="Position">Торговый представитель розничных продаж</attribute>
<attribute name="City">BAIKALSEA Company Иркутск</attribute>
<attribute name="Division">Отдел продаж</attribute>
<attribute name="Department">Продажи</attribute>
<attribute name="Email">yarosh@baikalsea.com</attribute>
<attribute name="MobPhone">79149274726</attribute>
<attribute name="WorkPhone">-</attribute>
<attribute name="Manager">Нет</attribute>
<attribute name="HonoredWorker">Нет</attribute>
<attribute name="Login">yarosh@baikalsea.com</attribute>
<attribute name="Character">Пользователь</attribute>
</Object>
And here is what I get converting it with encode/decode and simpleXml:
As you can see 'name' attribute and its value is lost. I need those name
attributes and their values as well. Pls any help appreciated.