[Project_owners] Reading siblings in XML..

Jawahar Swaminathan jawahar at ebi.ac.uk
Mon Feb 21 21:12:58 EST 2005


Hi,

I have an XML file which looks somewhat like this

<Groups>
<Group name="Structures">
<Menuitems>
<Menuitem Identity="Text Search">
<url>SomeUrl</url>
<url>SomeUrl</url>             
<url>SomeUrl</url>
</Menuitem>
</Menuitems>
</Group>
</Groups>

I try to read all the URL's under a particular Menuitem using the following:

var value = document.getElementById('queryTextbox').value; // This is an 
option chosen by the User
var bbdatabase = xmlDoc.getElementsByTagName("Menuitem");
for(var i=0; i<bbdatabase.length; i++) {
var MenuTerm = bbdatabase[i].attributes["Identity"].value;
        if(MenuTerm == value)
        {
            var urlT = 
bbdatabase[i].getElementsByTagName("url")[0].childNodes[0].nodeValue;
            for(var l=0; l<urlT.length; l++) {
            getBrowser().addTab(urlT+value);
            }
        }
  }

I would expect this to open the two URLs in the XML file. But I seem to 
get into this endless loop with only the first URL read in everytime. 
Obviously I am doing something very stupid. I read somewhere that I 
should probably be using getNextSibling but I have no idea how to do 
this. Any help much appreciated as usual.

regards,

Jawahar



More information about the Project_owners mailing list