Posted by Decavolt on 01/25/07 17:19
I'm building a nav structure in PHP that's using simplified XML files
to populate an unordered list. I have an xml parser that coverts my XML
to a multi-dimensional array, but I'm having issues getting by data out
of that array.
My xml file looks something like this:
<SECTION title="Search Engines">
<ITEM name="Google" url="www.google.com" />
<ITEM name="Yahoo" url="www.yahoo.com" />
</SECTION>
<SECTION title="Boogers">
<ITEM name="Slimy" url="slimy.com" />
<ITEM name="Crunchy" url="crunchy.com" />
</SECTION>
I'm very used to using a for loop over single-dim arrays but not so
much on mult-dim arrays. I'd like to output something like this:
<li class="title">Search Engines</li>
<li><a href="www.google.com">Google</a></li>
<li><a href="www.yahoo.com">Yahoo</a></li>
<li class="title">Boogers</li>
<li><a href="slimy.com">Slimy</a></li>
<li><a href="crunchy.com">Crunchy</a></li>
I've been looking at examples and pouring over php.net's docs to no
avail, and can't seem to get a loop structure that'll output what seems
like a very simple multi-dim array structure.
Can anyone point me in the right direction for that loop, or suggest a
better way for me to go about this?
[Back to original message]
|