SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Forums
SiteExperts.com Forums
All Discussions

SiteExperts Feedback
The Lounge
Dynamic HTML
Site Design/ Critiques
HTML and CSS
XML Technologies
The Wireless Internet
Internet Explorer
Microsoft .NET
The Server
Technical Support

Sponsored Links

User Groups : Forums : SiteExperts : Dynamic HTML :

Previous DiscussionNext Discussion
 An actual, real discussion! -- an XML menu...

Ok, here's what I'm looking to do.

Let's say I have an XML file that looks like this (excerpt):


<menu>
<item>Menu Item 1
<sub_item_1>Sub 1</sub_item_1>
<sub_item_2>Sub 2</sub_item_2>
<sub_item_3>Sub 3</sub_item_3>
</item>
<item>Menu Item 2</item>
<item>Menu Item 3
<sub_item_1>Sub 1
<sub_sub_item_1>Sub Sub 1</sub_sub_item_1>
<sub_sub_item_3>Sub Sub 2</sub_sub_item_2>
<sub_sub_item_3>Sub Sub 3</sub_sub_item_3>
</sub_item_1>
<sub_item_2>Sub 2</sub_item_2>
<sub_item_3>Sub 3</sub_item_3>
</item>
</menu>


Now, what I want to do is take this menu, and make it a vertical, multi-level menu.

I want to do this client-side (without a server-side language). I know how to load the XML, but I can't quite figure out how to traverse the menu and get the results I want.

What I'm looking for is your classic "file menu" functionality.

I've seen some very vague, very incomplete examples. I don't usually work with XML much, so that's why I'm asking here.

On Google, it turns up some stuff, but nothing like what I'm looking for.

Started By Monte on May 22, 2009 at 10:41:28 AM

9 Response(s) | Reply

Earlier Replies | Replies 4 to 9 of 9 | Later Replies
Goto Page: 2 1
BachusII on May 24, 2009 at 12:17:41 PM (# 4)

XSL translation? can't remember but there are examples somewhere on this website.


MHenke on May 25, 2009 at 6:40:40 AM (# 5)

I'm not sure how XSLT is supported on the client-side nowadays. If so, that could be quite an elegant option.

Apart from that, I can think of two other ways:
Data (DOM-) centric: Traverse (the whole) XML menu data using DOM-methods (like getFirstChild, getNextSibling, getWhateverNode).
More function centric: Selectively pull nodes from the XML menu data using XPath expressions.

In both cases you could use JavaScript DOM methods to build the menu elements within the HTML page, using the retrieved menu data.


Monte on May 25, 2009 at 6:49:51 AM (# 6)

"Data (DOM-) centric: Traverse (the whole) XML menu data using DOM-methods (like getFirstChild, getNextSibling, getWhateverNode).
More function centric: Selectively pull nodes from the XML menu data using XPath expressions."

Either of these would work, MHenke. I'm just not sure exactly how to do it. Could you point me to an example on the web?


MHenke on May 26, 2009 at 2:41:05 AM (# 7)

TBH, nope, I've never seen such code in a working example (tho I've done it server-side).
I'm just sure that it should. :)


BachusII on May 26, 2009 at 10:20:52 AM (# 8)

Surrounded by a lot of ajax, but it shows what I meant.
http://www.ibm.com/developerworks/xml/library/x-xmlajaxpt2/#listing6


Terry Young on Jun 11, 2009 at 9:58:14 AM (# 9)

XML DOM Traversing?

http://www.w3schools.com/Dom/dom_nodes_traverse.asp


Earlier Replies | Replies 4 to 9 of 9 | Later Replies
Goto Page: 2 1

To respond to a discussion, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password
Copyright 1997-2004 InsideDHTML.com, LLC. All rights reserved.