Reading Hierarchial XML elements in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kepardue
Forum Newbie
Posts: 8
Joined: Sun Aug 07, 2005 8:59 pm

Reading Hierarchial XML elements in PHP

Post by kepardue »

I'm trying to get my PHP to read a list of items from an XML file in the format of:

Code: Select all

<item identifier="ITEM-eXeed_rigging44f81a2d1cb8e8ff933" isvisible="true" identifierref="RES-eXeed_rigging44f81a2d1cb8e8ff934">
    <title>Advanced Rigging</title>
<item identifier="ITEM-eXeed_rigging44f81a2d1cb8e8ff935" isvisible="true" identifierref="RES-eXeed_rigging44f81a2d1cb8e8ff936">
    <title>Chapter 1</title>
</item>
<item identifier="ITEM-eXeed_rigging44f81a2d1cb8e8ff937" isvisible="true" identifierref="RES-eXeed_rigging44f81a2d1cb8e8ff938">
    <title>Chapter 2</title>
</item>
</item>
Such that I have nested <item> tags. I'm new to XPath and have found it to be useful for getting data like this, but for some reason

Code: Select all

$elements = $xpath->query('m:item');
seems to only produce one result with the contents of all of the combined tags.

Any advice would be useful.
Post Reply