I need to parse an XML file with PHP for an object. At the moment, I have no idea how to do this, help is welcome.
xml is pretty big. I need to analyze part of it that looks like this:
<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>
Each attribute "name" and "anAttribute" is unique.
What I would like to have later is a category object with many category objects ...
Thanks!
user228793
source share