473,385 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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
Jul 17 '05 #1
1 5369
Michael Champagne scribbled something along the lines of:
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


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/
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Justin Archie | last post by:
The subject says it all my friends. I have searched google to death about centering problems and for some reason no one seems to have the error I have. For the past few days I have been working on...
6
by: MikeSwann | last post by:
Dear All, I am trying to decide on to create a collection object for a project that I am working on. I am fairly new to OOP so this may be on the basic side. I have looked on the groups, but...
3
by: triplejump24 | last post by:
i LOVE doing c++ programming, but i never can get myself started! Once i figure it out, its fun but anyways here it goes... Im given a file c:\temp\hwk8input.txt, which contains the records of the...
3
by: User | last post by:
Hi, Is it possible to transform Ordered/Unordered list into navigation dropdown menus? Is this effect achieved by CSS? or via Javascript? PLease advise Thanks.
0
by: roscoedesign | last post by:
html: http://roscoecreations.com/exitpro/ css: http://roscoecreations.com/exitpro/css/style.css js: http://roscoecreations.com/exitpro/javascript/main.js Recently, I have had some big problems...
2
by: vidhyapriya | last post by:
Hi all, I am creating user controls for developing menu for my application.I am not using default menu bar,creating my own menu using user controls.I want my user controls above the form.For Example...
2
by: torweb | last post by:
I'm using an image for an unordered list, which works fine. The problem is, the image is also appearing in my numbered "ordered list." Here is my code for the unordered list:...and thanks in...
2
by: asc4john | last post by:
When including an unordered list in an unordered list: Should it be included as a "list" item as in: <ul><liitem</ li><ul.... </ul<liitem</li</ul> or included in the LI element as in:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.