我嘗試將簡單的xml文件轉換爲數組,但轉換不會將「id」屬性保留爲關鍵數組。 XML源:如何將具有屬性的XML文件轉換爲數組
<mapi>
<categoriesList>
<category id="310">Autres</category>
<category id="574">Bière</category>
<category id="495">Biscuits</category>
<category id="444">Bonbons</category>
<category id="435">Champagne</category>
<category id="371">Cidre</category>
<category id="215">Condiments</category>
<category id="8">Fruits</category>
<category id="445">Poissons</category>
<category id="578">Produits laitiers</category>
<category id="539">Spiritueux</category>
<category id="259">Viandes</category>
<category id="126">Vin</category>
</categoriesList>
</mapi>
標識是一個簡單的排列是這樣的:
array (
[310] => Autres
[574] => Bière
[495] => Biscuits
[444] => Bonbons
[435] => Champagne
[371] => Cidre
[215] => Condiments
[8] => Fruits
[445] => Poissons
[578] => Produits laitiers
[539] => Spiritueux
[259] => Viandes
[126] => Vin
)
感謝您的幫助 迪米特里
哪裏是你的代碼?你嘗試了什麼? – Uby 2013-03-21 18:07:57