Maybe is a trivial problem, i don't know why this function exit from for cycle when it goes on else statement. I need this function to fetch an xml document.
function xmlToArray(element){
    childs= element.childNodes;
    if(childs.length != 1){
      for(var i=0;i<childs.length;i++){
        if(childs[i].hasChildNodes()){
          xmlToArray(childs[i]);
        }
        alert("exit from if");
      }//end for
      alert("exit from for");
    }//end if
    else{
      alert("do something with element");
    }
    alert("end of func");
}