Connecting Tech Pros Worldwide Help | Site Map

Creating simple unordered list menu from XML?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 04:57 AM
Michael Champagne
Guest
 
Posts: n/a
Default Creating simple unordered list menu from XML?

Does anyone have any examples or links to examples of generating a
simple unordered list menu with multiple levels from an XML file? We
are redesigning the navigation on our website and I was hoping to make
this as flexible as possible.

Thanks,
Mike

  #2  
Old July 17th, 2005, 04:57 AM
Ashmodai
Guest
 
Posts: n/a
Default Re: Creating simple unordered list menu from XML?

Michael Champagne scribbled something along the lines of:
[color=blue]
> Does anyone have any examples or links to examples of generating a
> simple unordered list menu with multiple levels from an XML file? We
> are redesigning the navigation on our website and I was hoping to make
> this as flexible as possible.
>
> Thanks,
> Mike[/color]

http://www.php.net/xml

You could have a simple structure like

<?xml version="1.0"?>
<menu xmlns="http://www.example.com/menu" label="Navigation">
<category label="My stuff">
<entry label="Chimpanzee" href="/index/chimp"/>
<entry label="Red car" href="/index/car"/>
<category label="My weapons">
<entry label="One-handed sword" href="/index/weaps/sword"/>
<entry label="Battle Axe" href="/index/weaps/axe"/>
</category>
</category>
<category label="Random words">
<entry label="Zilch" href="/index/zilch"/>
<entry label="Squee" href="/index/squee"/>
<entry label="Splurt" href="/index/splurt/">
</category>
</menu>

And all you'd need would be a start-tag and end-tag element handler to
create the following partial HTML:

<h2>Navigation</h2>
<ul>
<li class="category">My stuff<ul>
<li><a href="/index/chimp/">Chimpanzee</a></li>
<li><a href="/index/car/">Red car</a></li>
<li class="category">My weapons<ul>
<li><a href="/index/weaps/sword/">One-handed sword</a></li>
<li><a href="/index/weaps/axe/">Battle Axe</a></li>
</ul></li>
</ul></li>
<li class="category">Random words<ul>
<li><a href="/index/zilch/">Zilch</a></li>
<li><a href="/index/squee/">Squee</a></li>
<li><a href="/index/splurt/">Splurt</a></li>
</ul></li>
</ul>

which could for example render like this:

*Navigation*

# /My stuff/
o _Chimpanzee_
o _Red_car_
o /My weapons/
+ _One-handed_sword_
+ _Battle_Axe_
# /Random words/
o _Zilch_
o _Squee_
o _Splurt_


You could also just use XSLT, but that's a little more complicated (IMHO).
The manual should tell you enough that you can do this on your own. If
you want me to write a script for you though, feel free to transfer € 75
to my PayPal account and I'll write you a simple function that does
what I just described.
--
Alan Plum, WAD/WD, Mushroom Cloud Productions
http://www.mushroom-cloud.com/
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.