Мне нужно разобрать XML-файл с PHP на объект. На данный момент у меня нет понятия, как это сделать, помощь приветствуется.Разбор вложенного xml с PHP на объект
xml довольно большой. Я должен разобрать часть, которая выглядит следующим образом:
<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>
Каждый «имя» и атрибут «anAttribute» является уникальным.
То, что я хотел бы иметь впоследствии находитесь в категории объекта со многими объектами категории ...
Спасибо!
Привет, Питер, большое спасибо! Это помогло мне начать. Но я еще не закончил, так что, может быть, мне придется снова спросить здесь. – 2009-12-11 02:09:43