Je dois analyser un fichier XML avec un objet PHP. Pour le moment, je n'ai pas la moindre idée de comment faire cela, l'aide est appréciée.Analyser un fichier XML imbriqué avec PHP dans un objet
Le format XML est assez volumineux. Je dois analyser une partie qui ressemble à ceci:
<someNamespace:xmlDocument>
<someNamespace:categories>
<category name="Patrick" anAttribute="numericValue" anotherAttribute="numericValue">
<category name="Andrew" anAttribute="numericValue" anotherAttribute="numericValue">
<category name="Alice" anAttribute="numericValue" anotherAttribute="numericValue">
<category name="Thomas" anAttribute="numericValue" anotherAttribute="numericValue">
<category name="Michael" anAttribute="numericValue" anotherAttribute="numericValue"/>
<category name="Matthew" anAttribute="numericValue" anotherAttribute="numericValue"/>
</category>
<category name="Janet" anAttribute="numericValue" anotherAttribute="numericValue">
<category name="Steven" anAttribute="numericValue" anotherAttribute="numericValue"/>
<category name="Christopher" anAttribute="numericValue" anotherAttribute="numericValue"/>
</category>
<category name="Sue" anAttribute="numericValue" anotherAttribute="numericValue"/>
</category>
<category name="Charles" anAttribute="numericValue" anotherAttribute="numericValue">
<category name="John" anAttribute="numericValue" anotherAttribute="numericValue">
<category name="Charles" anAttribute="numericValue" anotherAttribute="numericValue"/>
<category name="Rosamund" anAttribute="numericValue" anotherAttribute="numericValue"/>
<category name="Stuart" anAttribute="numericValue" anotherAttribute="numericValue"/>
<category name="Rosamund" anAttribute="numericValue" anotherAttribute="numericValue"/>
</category>
<category name="John" anAttribute="numericValue" anotherAttribute="numericValue"/>
</category>
</category>
<category name="Oliver" anAttribute="numericValue" anotherAttribute="numericValue">
<category name="Jane" anAttribute="numericValue" anotherAttribute="numericValue"/>
<category name="Lucy" anAttribute="numericValue" anotherAttribute="numericValue">
<category name="David" anAttribute="numericValue" anotherAttribute="numericValue"/>
<category name="Robert" anAttribute="numericValue" anotherAttribute="numericValue"/>
<category name="Hetty" anAttribute="numericValue" anotherAttribute="numericValue">
<category name="Kenneth" anAttribute="numericValue" anotherAttribute="numericValue"/>
<category name="Jonathan" anAttribute="numericValue" anotherAttribute="numericValue"/>
</category>
<category name="Freddy" anAttribute="numericValue" anotherAttribute="numericValue"/>
<category name="Virginia" anAttribute="numericValue" anotherAttribute="numericValue"/>
</category>
</category>
</category>
</someNamespace:categories>
Chaque « nom » et l'attribut « anAttribute » est unique.
Ce que je voudrais avoir plus tard est un objet catégories avec de nombreux objets de la catégorie ...
Merci!
Salut Peter, merci beaucoup! Cela m'a aidé à démarrer. Mais je n'ai pas encore terminé, alors je dois peut-être demander à nouveau ici. –