473,414 Members | 1,563 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,414 software developers and data experts.

xml js dynamic menu

gxlrygt
this is the dynamic menu of my site. it works clearly but i need a shorter and simpler function. help me pls. thanks



Expand|Select|Wrap|Line Numbers
  1. XML
  2. <root>
  3. <m t="1">
  4.     <m t="1.1"/>
  5.     <m t="1.2" />
  6.     <m t="1.3">
  7.         <m t="1.3.1" />
  8.         <m t="1.3.2" />
  9.     </m>
  10. </m>
  11. <m t="2">
  12.     <m t="2.1" />
  13. </m>
  14. <m t="3"/>
  15. </root>


Expand|Select|Wrap|Line Numbers
  1. JS
  2. x=x.childNodes;
  3. for (i=0;i<x.length;i++)
  4.   {
  5.   if (x[i].nodeType==1){
  6.   txt=x[i].attributes[0];
  7.   lnk=x[i].attributes[1];
  8.   if(txt) t+=txt.nodeValue;
  9.   if(lnk) t+="."+lnk.nodeValue;
  10.  t+="<br>";
  11.  
  12. y=x[i].childNodes;
  13. for (k=0;k<y.length;k++)
  14.   {
  15.   if (y[k].nodeType==1){
  16.   txt=y[k].attributes[0];
  17.   lnk=y[k].attributes[1];
  18.   if(txt) t+="---"+txt.nodeValue;
  19.   if(lnk) t+="."+lnk.nodeValue;
  20.  t+="<br>";
  21.  
  22. z=y[k].childNodes;
  23. for (j=0;j<z.length;j++)
  24.   {
  25.   if (z[j].nodeType==1){
  26.   txt=z[j].attributes[0];
  27.   lnk=z[j].attributes[1];
  28.   if(txt) t+="-----------"+txt.nodeValue;
  29.   if(lnk) t+="."+lnk.nodeValue;
  30.  t+="<br>";
  31.  
  32.   }
  33. }
  34.   }
  35. }
  36.   }
  37. }
Dec 12 '06 #1
1 1747
b1randon
171 Expert 100+
this is the dynamic menu of my site. it works clearly but i need a shorter and simpler function. help me pls. thanks



Expand|Select|Wrap|Line Numbers
  1. XML
  2. <root>
  3. <m t="1">
  4.     <m t="1.1"/>
  5.     <m t="1.2" />
  6.     <m t="1.3">
  7.         <m t="1.3.1" />
  8.         <m t="1.3.2" />
  9.     </m>
  10. </m>
  11. <m t="2">
  12.     <m t="2.1" />
  13. </m>
  14. <m t="3"/>
  15. </root>


Expand|Select|Wrap|Line Numbers
  1. JS
  2. x=x.childNodes;
  3. for (i=0;i<x.length;i++)
  4.   {
  5.   if (x[i].nodeType==1){
  6.   txt=x[i].attributes[0];
  7.   lnk=x[i].attributes[1];
  8.   if(txt) t+=txt.nodeValue;
  9.   if(lnk) t+="."+lnk.nodeValue;
  10.  t+="<br>";
  11.  
  12. y=x[i].childNodes;
  13. for (k=0;k<y.length;k++)
  14.   {
  15.   if (y[k].nodeType==1){
  16.   txt=y[k].attributes[0];
  17.   lnk=y[k].attributes[1];
  18.   if(txt) t+="---"+txt.nodeValue;
  19.   if(lnk) t+="."+lnk.nodeValue;
  20.  t+="<br>";
  21.  
  22. z=y[k].childNodes;
  23. for (j=0;j<z.length;j++)
  24.   {
  25.   if (z[j].nodeType==1){
  26.   txt=z[j].attributes[0];
  27.   lnk=z[j].attributes[1];
  28.   if(txt) t+="-----------"+txt.nodeValue;
  29.   if(lnk) t+="."+lnk.nodeValue;
  30.  t+="<br>";
  31.  
  32.   }
  33. }
  34.   }
  35. }
  36.   }
  37. }
What are you looking for specifically? Your function looks very cut and dry already. What are you unhappy with?
Dec 12 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Macamba | last post by:
Hi all, I am currently developing a website for a voluntary organisation. It is my first step in website development. The dynamic menu I developed has some bugs, which I addressed in another...
4
by: Stromboli | last post by:
hi people, My problem is that I need to build a dynamic menu (preferably that works in all the browsers) that appears when I mouseover a certain link. The problem is that I have to declare...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
1
by: biela | last post by:
Hi I'm from Poland and I have small question :). I'm looking for sample example how to create dynamic menu. Generaly my website will see like that ------------------------------------ 2...
2
by: vikram | last post by:
I have to design a page which contains a dynamic generated menu at left side.Menu will be generated once a user log in and will remain as it is for the rest of the user session. Problem is that...
19
by: mart2006 | last post by:
I've created a dynamic drop down menu that populates itself with data from a MySQL table. What I would like to do is create a non dynamic drop down menu that alters what is shown in the dynamic menu....
3
by: RahimAsif | last post by:
I am writing an application that requires the a portion of the main menu to be dynamic. The menu has file, panels, view files and help across the top. The view files sub menu needs to be...
0
by: benfly08 | last post by:
Hi, I used SWT to develop an windows application. In the application there is a dynamic created popup menu. The dynamic part is that i will pass a list of name to be a submenu of one menu item....
10
by: mart2006 | last post by:
Hi, I'm fairly new to PHP and I've created a dynamic drop down menu that populates itself with data from a MySQL table. What I would like to do is create a non dynamic drop down menu that alters...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.