473,396 Members | 2,002 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,396 software developers and data experts.

XML Javascript Explorer Tree Question

1
Hello Everyone,

I am new to javascript and the XMLDOM, this is my first post in th forum :)

I am trying to populate the content of a javascript created explorer tree using an XML document. Below is a snip of code outlining where I am running into a problem. I have loaded a document but I can't seem to access the content and apply it to the constructer argument for my new leaf method, which takes a text string and a link argument.

Leaf Constructor:
Expand|Select|Wrap|Line Numbers
  1. function leaf(text, link)
  2.     {
  3.  
  4.         this.text = text;
  5.         this.link = link;        
  6.         this.write = writeLeaf;
  7.  
  8.     }
  9.  
Main Function:
Expand|Select|Wrap|Line Numbers
  1. function main()
  2.     {
  3.         //experiment code
  4.         xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  5.         xmlDoc.load("db.xml");
  6.         var x = xmlDoc.getElementsByTagName('Manual');
  7.         var myTree = new tree();
  8.         var branch1 = new branch(branch1,'Maintennace Manuals');
  9.         var branch2 = new branch('branch2','B 737 MEL');
  10.         // loop for leaves
  11.         for (j=0;j<x[0].childNodes.length;j++)
  12.         {            
  13.             if (x[0].childNodes[j].nodeType != 1) continue;
  14.             branch2.add(new leaf('Leaf 1','http://yahoo.com'));            
  15.         }                
  16.         branch1.add(branch2);
  17.         myTree.add(branch1);         
  18.         myTree.write();    
  19.     }  
  20.  
XML Content
Expand|Select|Wrap|Line Numbers
  1. <Manuals>
  2.   <Manual name="'B737 MEL'">
  3.     <Section_00 name='http://yahoo.com'>Section_00</Section_00>
  4.       <Section_01 name='http://msn.com'>Section_01</Section_01>
  5.   </Manual>
  6. </Manuals>
  7.  

You will notice I am using garbadge parameters in the new leaf constructor. I want set the name and path from the content of the XMl file. When I use code to replace the argument strings I will end up ith things like undefined or [object].


Any ideas as to what I amy be doing wrong.

Thanks in advance.
Apr 1 '08 #1
2 1729
pronerd
392 Expert 256MB
Are you sure that the for loop is actually being entered? Also what is the purpose of the if test in the for loop? No matter what it finds the next line will execute since it just does a continue.
Apr 1 '08 #2
jkmyoung
2,057 Expert 2GB
You're probably setting the value to the object pointer, as opposed to the string.
Could you show us the code you're using when you don't have garbage objects there?
Apr 2 '08 #3

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

Similar topics

13
by: Kai Grossjohann | last post by:
It seems that Ctrl-N in Mozilla opens a new empty browser window. That's fine, I don't need to do anything about it. But Ctrl-N in IE appears to clone the current window. Is there a way to...
11
by: Dag Sunde | last post by:
We have this web-app that requires Javascript to be enabled in the UA (this is okay'ed by our customer). Now I want to make a "pre" page before the login screen, informing the user that he/she...
1
by: Steve Randall | last post by:
I am building a utility application that uses much of the same functionality as already exists in the Windows Explorer. It would therefore make sense to use (if possible) the Windows Explorer as the...
1
by: Jason Robertson | last post by:
Hi, I have just installed Visual Studio.net 2003 Enterprise Architect. I have been using Visual Interdev so far, and I am used to be able to select from a desktop bunch of .asp files, drag and...
1
by: Satish.Talyan | last post by:
hi, i want to create a dynamic tree hierarchy in javascript.there are two parts in tree, group & user.when we click on group then users come under that's tree category will be opened.problem is...
1
Frinavale
by: Frinavale | last post by:
Hi there! I'm not sure if this question should be posted under the .NET form or the JavaScript form...I just have a general question about JavaScript and .NET. I usually test my JavaScript in...
4
by: shinichi81 | last post by:
Could anyone help me? After updating icon for a drive, for example C drive by specifying icon file at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\C\DefaultIcon,...
9
by: -Lost | last post by:
http://blogs.msdn.com/ie/archive/2007/12/19/internet-explorer-8-and- acid2-a-milestone.aspx Oh my! A somewhat standards compliant Internet Explorer? What about JavaScript? Not that it proves...
2
by: Holger Jeromin | last post by:
Hello, i need to add SVG things direct in a Website. I know XHTML is best used for that, with works nice in Firefox and Opera. Internet Explorer is more challenging... I have ported my...
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: 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?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.