XML Grouping

Posted on 16th Feb 2014 by admin

I'm using xml_parse_into_struct to get all my elements, but now I need to group them. For example, here's the XML

<categories>
<category id="12345">
<title>category title 1</title>
<tips>
<tip id="0">
<title>hello world</title>
<content>some content</content>
</tip>
<tip id="1">
<title>foo</title>
<content>foo content</content>
</tip>
</tips>
</category>
<category id="7890">
<title> category title 2</title>
<tips>
<tip id="2">
<title>another tip title</title>
<content>blah blah</content>
</tip>
<tip id="3">
<title>another tip title</title>
<content>blah blah</content>
</tip>

</tips>
</category>
</categories>


How would I just grab the tip titles for the 2nd category (7890)? Hope I'm making sense.
I can loop through the array using foreach, but have no way to determine if a tip belongs to the 1st or 2nd category. Ideas??

Please help!

Thanks

Other forums