Ariel_medel 0 Newbie Poster

I have this code:

txt4="<div style='margin-top:4px'>";
  for (n=0;n<xy.length;n++)
  {
	  txt4=txt4 + "<div>";
  iconsb=xy[n].getElementsByTagName("SUBLINK");
  iconsb2=xy[n].getElementsByTagName("SUBCLASS");
  iconsb3=xy[n].getElementsByTagName("SUBCOPY");
  
 
  subclass=xy[n].getElementsByTagName("SUBCLASS")[0].childNodes[0].textContent;
  subcopy=xy[n].getElementsByTagName("SUBCOPY")[0].childNodes[0].textContent;

  
  
   {
	try      
      {
		 
    if (subclass==="download_pod"||subclass==="download_arrow"||subclass==="video") { var down="<a id='" + subclass + "' style='float:right; display:inline-block; margin-left:1em' href='" + iconsb[0].childNodes[0].textContent + "' class='" + subclass + "'>" + subcopy + "</a>"}	
	
    else if (subclass==="extra_h3"||subclass==="extra_p") { var down="<span id='" + subclass + "' class='" + subclass + "'>" + subcopy + "</span>"}
	
	
	else { var down="<a id='" + subclass + "' style='float:right; display:inline-block; margin-left:1em' href='javascript:void(0);' onclick='cosas_pod(" + i + "," + n + ")' class='" + subclass + "'>" + subcopy + "</a>"}
	txt4;	
    
  

txt4=txt4 + down;

}
    catch (er)
      {
      txt4=txt4 + "</a> </a>";
      }
    }
  
  txt4=txt4 + "</div>";
  }
txt4=txt4 + "</div>";

But I want to simplify it by doing this (the following code is an extract of the one above):

sublink=xy[n].getElementsByTagName("SUBLINK")[0].childNodes[0].textContent;
  subclass=xy[n].getElementsByTagName("SUBCLASS")[0].childNodes[0].textContent;
  subcopy=xy[n].getElementsByTagName("SUBCOPY")[0].childNodes[0].textContent;

  
  
   {
	try      
      {
		 
    if (subclass==="download_pod"||subclass==="download_arrow"||subclass==="video") { var down="<a id='" + subclass + "' style='float:right; display:inline-block; margin-left:1em' href='" + sublink + "' class='" + subclass + "'>" + subcopy + "</a>"}

but the sublink variable does not work, no content is loaded from the xml file.If I only use subclss and subcopy it does work. What could be the problem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.