我尝试将简单的 xml 文件转换为数组,但转换不会将“id”属性保留为键数组。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
)
谢谢你的帮助迪米特里